Is -C useless?
Paul LeoNerd Evans
leonerd at leonerd.org.uk
Thu Sep 11 13:11:58 BST 2008
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?
--
Paul "LeoNerd" Evans
leonerd at leonerd.org.uk
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://london.pm.org/pipermail/london.pm/attachments/20080911/3f8f1c22/signature.pgp
More information about the london.pm
mailing list