Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!oakhill!billl From: billl@oakhill.UUCP (Bill Ledbetter) Newsgroups: comp.lang.perl Subject: Problems with pack. Keywords: pack,unpack,unsigned Message-ID: <3105@jupiter.oakhill.UUCP> Date: 18 Mar 90 21:06:41 GMT Organization: Motorola Inc. Austin, Tx Lines: 39 I seem to be having problems with the unsigned pack/unpack operations. I am running: $Header: perly.c,v 3.0.1.4 90/02/28 18:06:41 lwall Locked $ Patch level: 15 on a sun3 with SunOS 3.5. The following script shows the problem: # ------------------------------------ #!/usr/local/perl3 -s $[ = 1; $lw[1] = hex("01234567"); $lw[2] = hex("89abcdef"); $binI = pack("I2", @lw); @newI = unpack("I2", $binI); # Prints out "01234567 00000000" printf "%08x %08x\n", $newI[1], $newI[2]; $bini = pack("i2", @lw); @newi = unpack("i2", $bini); # Prints out "01234567 89abcdef" printf "%08x %08x\n", $newi[1], $newi[2]; ------ This seems to be counter-intuitive. Is this a bug, or am I doing something really stupid... --------------------------------------------------------------------------- Bill Ledbetter Motorola Inc. MD OE37 email: cs.utexas.edu!oakhill!billl 6501 William Cannon Dr. West Austin, TX 78735-8598