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:

print $ARGV[0];

Now if I run the program as follows:

$ ./ "FOO\n\n\n"

I get


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.


Relevant Pages

  • Re: Speeding up writes to STDOUT
    ... e9> So my little Perl program is reading a giant chunk of data from a MySql ... e9> slow because of the overhead added by formatting. ... buffering. ... after you are done with all the sprintf calls just print that buffer. ...
  • Re: How to display the contents of (or open) a file
    ... cases when there is formatting included in the output file. ... sounds like you are not dealing with a normal ASCII or UTF-8 text ... read the data into a data structure that preserves the structure of ... In order to "open" or start a file from within a Perl program, ...