[comp.lang.perl] unpack query.

des0mpw@colman.newcastle.ac.uk (M.P. Ward) (04/25/91)

Why isn't "HH" the same as "H2" in unpack? An example:

print unpack("H2","A");		gives "41" as expected
print unpack("HH","A");		gives "4" as unexpected!

This is with perl version 4.0, Patch level: 3, SunOs 4.1, Sun 3/80

		Martin.

JANET: Martin.Ward@uk.ac.durham    Internet (eg US): Martin.Ward@durham.ac.uk
or if that fails:  Martin.Ward%uk.ac.durham@nfsnet-relay.ac.uk  
or even: Martin.Ward%DURHAM.AC.UK@CUNYVM.CUNY.EDU
BITNET: Martin.Ward%durham.ac.uk@UKACRL UUCP:...!ukc!durham!Martin.Ward

lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (04/26/91)

In article <1991Apr25.085953.29117@newcastle.ac.uk> des0mpw@colman.newcastle.ac.uk (M.P. Ward) writes:
: Why isn't "HH" the same as "H2" in unpack? An example:
: 
: print unpack("H2","A");		gives "41" as expected
: print unpack("HH","A");		gives "4" as unexpected!
: 
: This is with perl version 4.0, Patch level: 3, SunOs 4.1, Sun 3/80

H, h, B and b always align to a byte boundary when they're done.  It just
seemed a little silly to keep track of where in the current byte we were,
I guess.

Larry