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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Bug in perl -C (Unicode) option parsing?
by ikegami (Patriarch) on Feb 13, 2007 at 04:43 UTC | |
by benizi (Hermit) on Feb 14, 2007 at 18:41 UTC | |
Re: Bug in perl -C (Unicode) option parsing?
by Khen1950fx (Canon) on Feb 13, 2007 at 07:18 UTC | |
by ikegami (Patriarch) on Feb 13, 2007 at 07:25 UTC | |
by Khen1950fx (Canon) on Feb 13, 2007 at 07:39 UTC |
Back to
Seekers of Perl Wisdom