Re: strings with formatted characters in %ARGV



<mfrost8@xxxxxxxxx> wrote in comp.lang.perl.misc:
I thought I knew perl pretty well, but then this came up and has me
totally stumped -- making me realize I don't understand it as well as
I thought...

I'm trying to pass one or more formatted (i.e. with '\n' in it)
strings to a perl program and have them print with the formatting.
Consider the following perl code:

#!/usr/bin/perl
print $ARGV[0];

Now if I run the program as follows:

$ ./x.pl "FOO\n\n\n"

I get

FOO\n\n\n$

This is discussed in the FAQ "How can I expand variables in text strings?".
While you want to expand escape sequences and not variables, the reason
for the behavior and the solutions are similar.

Anno
.