perl-unicode

How to make -C work on shebang line?

2006-06-01 16:08:52

Something that worked under 5.8.7 does not seem to work under 5.8.8:

I want put both a "-I/lib/path" and a "-C.." on the shebang line:

onehost$ cat junk.pl
#!/usr/bin/perl -I/home/graff -CS
print chr(hex("01ff")),"\n"

onehost$ perl -v

This is perl, v5.8.7 built for i386-freebsd-64int
...

onehost$ junk.pl | od -txC
0000000    c7  bf  0a                                                    
0000003


otherhost$ perl -v

This is perl, v5.8.8 built for amd64-freebsd
...

otherhost$ junk.pl | od -txC
Wide character in print at ./junk.pl line 2.
0000000    c7  bf  0a                                                    
0000003


The problem is the "Wide character" warning, which means that "-CS",
when not by itself on the shebang line, is not handled properly in
5.8.8, whereas it had been in 5.8.7.  This gets in the way when I want a
"while (<>)" to do the right thing on unicode files in @ARGV as well as
unicode text on STDIN.

I also noticed, in both perl versions, that putting anything after -C.. 
on the shebang line causes an error:

onehost$ cat junk.pl
#!/usr/bin/perl -CS -w
print chr(hex("01ff")),"\n"

onehost$ junk.pl
Unknown Unicode option letter ' ' at /home/graff/junk.pl line 1.

otherhost$ junk.pl
Unknown Unicode option letter ' ' at /home/graff/junk.pl line 1.


I think this is a bug that should be fixed.  But in the meantime, is
there a way to make sure that "-C" will always work as intended on the
shebang line?  Or alternatively, is there an easy way to make sure that
all file handles (including STDIN, STDOUT and ARGV) are set to :utf8
without having to do "binmode()" on every handle?

Thanks,
        David Graff


<Prev in Thread] Current Thread [Next in Thread>