Is -C useless?
Philip Skinner
me at philip-skinner.co.uk
Thu Sep 11 13:20:04 BST 2008
On Thu, 2008-09-11 at 13:11 +0100, Paul LeoNerd Evans wrote:
> Consider the following:
>
> #!/usr/bin/perl -COL
>
> print "Hello w\xe9rld\n";
>
> $ perl test.pl
> Too late for "-COL" option at test.pl line 1.
>
> WTF?? If that's "too late", where else can I put it?
>
> If I remove it from the file:
>
> $ perl -COL test.pl
> Hello wérld
>
> But of course now STDOUT isn't UTF-8.
>
> $ perl test.pl
> Hello w�ld
>
> This can be fixed by:
>
> #!/usr/bin/perl
>
> binmode STDOUT, ":utf8" if $ENV{LANG} =~ m/\.UTF-8$/;
>
> print "Hello w\xe9rld\n";
>
> $ perl test.pl
> Hello wérld
>
> But of course, this is the exact behaviour that -COL is supposed to
> provide; and yet is "too late" by the shebang time.. Yet, clearly not
> because I can do it even later at runtime.
>
> Can anyone offer any insight here?
>
Maybe:
chmod 755 test.pl
./test.pl
?
More information about the london.pm
mailing list