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

In reply to Bug in perl -C (Unicode) option parsing? by benizi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.