> I cant find a simple perl function to replace characters in a string. Im
> trying to inserts strings like "bob's" into a database and need to convert
> that to "bob''s" so that sql doesnt whine when i do an insert.
> 
> Any suggestions?
> 

There are regex's and the tr/y functions/operators? But in this case you
shouldn't use either and instead use binding (assuming you are using
DBI, are you?).  Binding allows DBI/DBD which is very smart decide how
the data needs to be quoted rather than attempting to do this manually
which usually just leads to problems.

http://search.cpan.org/~timb/DBI-1.42/DBI.pm#Placeholders_and_Bind_Values

Alternatively if binding can't be used, there is the 'quote' method for
handling this specific task (on same page as above).

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to