Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Escape from backslash hell

by chipmunk (Parson)
on Dec 01, 2001 at 09:57 UTC ( [id://128838]=note: print w/replies, xml ) Need Help??


in reply to Escape from backslash hell

all of my attempts thus far have failed to produce the desired result, all return either the original string or 11\\/29\\/2001.
I wonder if you're checking the results in the debugger... Be aware that if you examine the contents of a variable (with x, X, or V), the debugger will escape quotes and backslashes, in order to produce a valid quoted string. However, if you print the contents of a variable (with p or print), you get just the contents.

Here's an example, showing that your second attempt works, although the debugger's output might be a bit misleading:

DB<1> $_ = "2001/11/30" DB<2> s{/}{\\/}g DB<3> x $_ 0 '2001\\/11\\/30' DB<4> p $_ 2001\/11\/30 DB<5>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-28 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found