http://www.perlmonks.org?node_id=599630

benizi has asked for the wisdom of the Perl Monks concerning the following question:

Today I came upon a quirk (bug?) of shebang/hash-bang line argument parsing. Past experience (and perlrun) tells me that perl (lowercase) parses commandline options from the shebang line:

$ cat test-none.pl #!/usr/bin/perl print "foo"; $ cat test-ell.pl #!/usr/bin/perl -l print "foo"; $ perl -l test-none.pl foo $ perl test-ell.pl foo $ ./test-ell.pl foo $ ./test-none.pl foo$ # note the lack of a newline

So, why do I get the wide-character warning in the following:

$ cat test-noCDS.pl #!/usr/bin/perl -l print "\x{101}"; $ cat test-withCDS.pl #!/usr/bin/perl -l -CDS print "\x{101}"; $ perl -l -CDS -e 'print "\x{101}"' $ perl -CDS test-noCDS.pl $ perl test-withCDS.pl Wide character in print at test-withCDS.pl line 2. $ ./test-withCDS.pl

Even more mysteriously, it seems the -CDS is getting applied (as seen by testing ${^UNICODE}), but not to STDOUT:

$ cat CDS.pl #!/usr/bin/perl -l -CDS print ${^UNICODE}, ' ', "\x{101}" $ perl CDS.pl Wide character in print at CDS.pl line 2. 31 $ perl -CDS CDS.pl 31

Is this a bug? If so, is it merely a documentation bug? (need a warning that -C doesn't get applied in time to affect STD(IN|OUT|ERR) if it's in a shebang?)

$ perl -v This is perl, v5.8.8 built for i686-linux