Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Escaping Apostrophe (updated)

by AnomalousMonk (Chancellor)
on Oct 20, 2017 at 16:08 UTC ( #1201765=note: print w/replies, xml ) Need Help??


in reply to Re^2: Escaping Apostrophe
in thread Escaping Apostrophe

Quick, dirty — and, per other replies, kinda crazy (and also untested):

my ($row_sub_i_esc_sq = $row[$idx]) =~ s{ ' }{\\}xmsg; $updstmt .= $hdr[$idx]." = '". $row_sub_i_esc_sq ."' \r\n";
And BTW: It looks like you're dealing with single-quote characters, not apostrophes.

Update: Oops... Meant to write  s{ (?= ') }{\\}xmsg; and the substitute-on-assignment expression is also wrong, so finally (I think):

(my $row_sub_i_esc_sq = $row[$idx]) =~ s{ (?= ') }{\\}xmsg; $updstmt .= $hdr[$idx]." = '". $row_sub_i_esc_sq ."' \r\n";
Thanks choroba. Of course, that's what always happens when I post untested stuff.


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1201765]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2018-07-21 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (446 votes). Check out past polls.

    Notices?