Steve Grazzini wrote: > On Dec 30, 2003, at 12:30 PM, Randy W. Sims wrote: > > If you have a string that is going to need escaping, consider > > using /\Q$string\U/ to handle quoting regex special chars. > > Right -- but that should be \E (for "end") instead of \U (the > mnemonic for which is "uppercase", not "unquote"). > > % perl -le 'print "\Qxxx\Uyyy"' > xxxYYY
Which all makes a very good argument for the clearly named quotemeta: Greetings! E:\d_drive\perlStuff>perl -w print "What's on your mind?\n"; my $input_line = <STDIN>; chomp $input_line; my $escaped_string = quotemeta $input_line; print "That's pretty bloody cryptic, y'know. Howzabout a complete sentence?\n"; my $full_line = <STDIN>; if ($full_line =~ /$escaped_string/) { print"the escaped string worked\n"; } else { print "escaping didn't help, dangitall!\n"; } if ($full_line =~ /$input_line/) { print "The input line worked all on its lonely, anyway.\n"; } else { print "Maybe the escaped one did it?\n"; } ^Z What's on your mind? $5.00 to [EMAIL PROTECTED] That's pretty bloody cryptic, y'know. Howzabout a complete sentence? I owe $5.00 to [EMAIL PROTECTED], and I don't have it. the escaped string worked Maybe the escaped one did it? Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>