$find="C:\\Dir1\\Dir2\\Dir3"; $replace=''; $var = "C:\\Dir1\\Dir2\\Dir3\\KeepMe"; $var =~ s/$find/$replace/eeg; print "\$var: $var\n";
The first line interpolates the double quoted string, converting "\\" to '\'.
The fourth line also interpolates the string.
Try using either $find='C:\\Dir1\\Dir2\\Dir3'; or better yet use $find = qr/C:\\Dir1\\Dir2\\Dir3/;.
In reply to Re: Help with regex using variables
by jwkrahn
in thread Help with regex using variables
by FFSparky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |