Pop quiz! What does this perl 5 program prints when executed with no arguments?
if (! @ARGV)
exec($^X, $0, "hello world");
my $arg = shift(@ARGV);
print "Got <$arg>\n";
print "Other args are <@ARGV>\n";
The answer is "it depends.". On my Linux system it prints "Got <hello world>", while on Windows, using Strawberry Perl, it prints "Got <hello>" and later on that the other args are "world".
I would expect the Linux behaviour were every argument passed to the list exec arrives as one argument to @ARGV regardless of whitespace as the correct. It also the behaviour exhibited on both operating systems using system. Is this a bug?
perlport only has this
to say about whitespace:
Whitespace in filenames is tolerated on most
systems, but not all, and even on systems where it might be tolerated, some
utilities might become confused by such whitespace..
I discovered this strange mis-behaviour when working on a commission for a client who is Windows-based.