($file2 = $file1) =~ s/\Q$dir1/$dir2/;
Since you have backslahes inside of the pattern you need use \Q to disable pattern metacharacters.
Also you don't need any modifiers (esg) for the regexp, excepting i probably.
see perldoc perlre
In reply to Re: problem in substitution
by ccn
in thread problem in substitution
by azaria
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |