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...