Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Single Quotes - how to avoid any escape processing?

by soonix (Canon)
on Aug 25, 2019 at 18:37 UTC ( #11104996=note: print w/replies, xml ) Need Help??


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 (Bishop) 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:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2020-07-12 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?