in reply to Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0
Just for fun, here is a fix to your function.
use strict; use warnings; my $message = q(O'REILLY); my $sql_message = sql_escape( $message); print "$sql_message"; sub sql_escape { my $text = shift; $text =~ s/'/\\'/g; $text =~ s/"/\\"/g; return $text; }
Use the module!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0
by wink (Scribe) on Jul 26, 2012 at 21:17 UTC | |
by lancer (Scribe) on Jul 27, 2012 at 08:00 UTC |