Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Interpretting character combinations as special characters.

by vitoco (Friar)
on Dec 11, 2009 at 18:27 UTC ( #812417=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Interpretting character combinations as special characters.
in thread Interpretting character combinations as special characters.

You are right... I should have begun with a big warning about how evil could eval be.

Fortunately, OP is processing one char at a time, and I couldn't think of a one-byte malicious code. ;-)

BTW, the first solution I though was this:

$text = 'h\te\nl\l\t\(o\)\n'; print "$text\n"; %token = ('\n'=>"\n", '\t'=>"\t" , '\('=>'(', '\)'=>')'); $text =~ s/(\\.)/$token{$1}||$1/ges; print "$text\n";

That will preserve unknown escape codes from text...

Also, thanks to JavaFan, // operator was new to me...


Comment on Re^3: Interpretting character combinations as special characters.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2015-07-05 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls