Peter Daum wrote:
>
I am looking for an way to interpolate backslash-sequences
within a string with the usual perl semantics, e.g.
$s='1\t\2\t3\na\ b c' should become:
'1<tab>2<tab>3
a b c'

Things I tried were for example
$s= eval('' . "$val"); # (hoping to trigger the normal interpolation) or
$s=~ s/\\(.)/"\\$1"/eg;
but somehow i couldn't get it right ...

Can anybody think of an elegant solution?

eval "qq($val)";

But note that the "\2" in your string (I don't know if it's a typo) will become
a character with an octal value of 2, i.e. the ASCII STX control character.

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to