... your $PathOnly is in double quotes, so the backslashes there are interpreted as escape sequences. #### c:\@Work\Perl\monks>perl -wMstrict -le "my $PathOnly = qq{c:\Dir1\Dir2\taint_so}; print qq{>$PathOnly<}; " Unrecognized escape \D passed through at -e line 1. Unrecognized escape \D passed through at -e line 1. >c:Dir1Dir2 aint_so<