http://qs321.pair.com?node_id=11104996


in reply to Re: Single Quotes - how to avoid any escape processing?
in thread Single Quotes - how to avoid any escape processing?

Corion already commented on the problem you noted, but there's another: your $PathOnly is in double quotes, so the backslashes there are interpreted as escape sequences.

Also, should you ever be in need of a string consisting of a single backslash, you could use "\N{REVERSE SOLIDUS}" (prior to v5.16, you have to use charnames explicitly for this to work). That is complicated, but whoever reads that, will have no doubt that you indeed want a single backslash that is not part of an escape secuence.

Replies are listed 'Best First'.
Re^3: Single Quotes - how to avoid any escape processing?
by AnomalousMonk (Archbishop) on Aug 25, 2019 at 18:54 UTC
    ... your $PathOnly is in double quotes, so the backslashes there are i +nterpreted as escape sequences.

    SteveDC:   Ah, yes!

    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<
    Don't know how you missed the warnings. You do have warnings enabled, right? Right?


    Give a man a fish:  <%-{-{-{-<