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

Re^3: Interpretting character combinations as special characters.

by vitoco (Pilgrim)
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 wandering the Monastery: (3)
As of 2014-07-13 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (245 votes), past polls