in reply to Reading Binary file confusion
print length pack 'H4C3H4b12H4'; # prints 11 H4 : 4 nybbles = 2 bytes C3 : 3 chars = 3 bytes H4 : 4 nybbles = 2 bytes b12: 12 bits!! = 2 bytes H4 : 4 nybbles = 2 bytes -- 11 bytes
But perhaps you wish to ignore the other 9 bytes in the header.
Unpacking the third field with "H4" gives you a hex string so you should probably use hex() to convert it to an integer. However, if it is a count of the blocks to follow then you could more easily unpack it with "v" or "n" depending on the endianness.
Also in your debug code you can use "H*" as a template for an unknown number of bytes.
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Reading Binary file confusion
by Anonymous Monk on Mar 12, 2002 at 00:15 UTC |