I’m using ActiveState perl 5.12.4 on Windows 7. I’m trying to execute a search and replace …
print "selected dir: $selected_dir basedir: $baseTestDir\n";
$selected_dir =~ s/$baseTestDir//g;
Where $selected_dir = "\home\selenium\projects\myco\AutomatedTests\MyCliUSA\Critical Path\Live\G Sedan" and $baseTestDir = "\home\selenium\projects\myco\AutomatedTests\MyCliUSA". However, after the search and replace statement, $selected_dir is unchanged. How can I properly implement a search and replace here?
You didn’t convert the text in
$baseTestDirinto a regex pattern. This can be usingquotemeta.It’s also accessible via
\Q..\Ein double-quoted and similar string literals.A trailing
\Ecan be omitted.