M
mfrost8
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$
which I don't understand. If I set a scalar string within the program
similarly:
#!/usr/bin/perl
my $foo = "FOO\n\n\n";
print $foo;
I get what I'd expect.
What am I missing here? Why can't I get print/printf to honor those
special characters when used from the command line?
Thanks
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$
which I don't understand. If I set a scalar string within the program
similarly:
#!/usr/bin/perl
my $foo = "FOO\n\n\n";
print $foo;
I get what I'd expect.
What am I missing here? Why can't I get print/printf to honor those
special characters when used from the command line?
Thanks