Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Regex match inside quotes doesn't work

by choroba (Chancellor)
on Sep 09, 2013 at 09:31 UTC ( #1052989=note: print w/replies, xml ) Need Help??


in reply to Regex match inside quotes doesn't work

$search contains backslashes that should not be interpreted as special characters. Use \Q to quote the special characters:
if (not $string =~ s/\Q$search/$replace/) {

Note that / can be used as the delimiter, since neither the pattern nor the replacement contain literal slashes.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ