On Tue, Sep 30, 2003 at 08:38:52PM -0000, jgeisler@css.tayloru.edu (via RT) wrote: > For some values for pack(), the wrong bits are being set. I don't > know where those extra bits come from. This problem exists for the i > and I templates. The following should illustrate the problem well. > > [236] john:~/JGG/marie % cat JGG.pl > #!/usr/bin/perl -w > > print_instruction(10 << 12); > > sub print_instruction { > my $instruction = shift; > > if (0) { > print "$instruction\n"; > } else { > print pack("L", $instruction); > } > } > [237] john:~/JGG/marie % ./JGG.pl | od -x > 0000000 c200 00a0 0000 > 0000005 > [238] john:~/JGG/marie % > > As you can see, the extra bits "c2" are added to the packed value. > 10 << 12 is definitely positive and the correct value should be > 0000 00a0 since this is a little endian machine. Sorry for the delay in replying. You problem is caused by an interaction between the way Perl 5.8.0 handles UT8 locales, and the fact that Redhat 9 enables UTF8 locales by default. Because you have this environment variable set to something including UTF-8, > LANG=en_US.UTF-8 Perl 5.8.0 by default does its output in UTF8. The two solutions are either to upgrade to Perl 5.8.1, or to remove UFT8 from any locale environment variables. Regards, Dave M. -- print+qq&$}$"$/$s$,$*${$}$g$s$@$.$q$,$:$.$q$^$,$@$*$~$;$.$q$m&if+map{m,^\d{0\,},,${$::{$'}}=chr($"+=$&||1)}q&10m22,42}6:17*2~2.3@3;^2$g3q/s"&=~m*\d\*.*gThread Previous