How can I interpolate literal \t and \n in Perl strings?

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-14T15:36:32Z Indexed on 2010/05/14 23:04 UTC
Read the original article Hit count: 143

Filed under:

Say I have an environment variable myvar:

myvar=\tapple\n

When the following command will print out this variable

perl -e 'print "$ENV{myvar}"'

I will literally have \tapple\n, however, I want those control chars to be evaluated and not escaped. How would I achieve it?

In the real world $ENV residing in substitution, but I hope the answer will cover that.

© Stack Overflow or respective owner

Related posts about perl