in reply to Substituting literal strings for escape characters

One way using eval is:
my $x = '\t\t\n\t\n\n'; eval "\$x = \"$x\""; print "$x";

Replies are listed 'Best First'.
Re: Re: Substituting literal strings for escape characters
by xmath (Hermit) on Feb 18, 2003 at 16:23 UTC
    Just for fun, try that with:
    my $x = '";warn q[this is code!] for 1..20;"';
    :-)

    Hint: Don't use eval() carelessly... your version allows arbitrary code to be placed in the input string, which will get executed

      Good point. I don't typically use eval on data that comes in externally -- only on data my program controls.