Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function in perl related to the addslashes() function in PHP

Status
Not open for further replies.

Troniac

Technical User
Mar 4, 2003
4
0
0
US
Can someone tell me the addslashes() function for perl?
I tried something with htmlentities but this don't work for me :(
 
excuse me i forgotten to describe.
This function automated add Slashes to a string because of the document.write() function in Javascript. But i avoid this problem in Java thanks any way.

But i want to know if there is any function doing like that.

$string = "Hello// this is a string\\?"
$string = addslashes($string);

that is now in $string
"Hello \/ this is a string \\?"
 
According to this documentation:
It just goes through a string and escapes a few specific characters (' " \ NULL) to make it database-friendly. I think there's DBI quote functions I've seen mentioned before, but it could be done with a regular expression, too.

$string =~ s/("|'|\\|\x00)/\\$1/g; ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top