in reply to Trouble understanding pack/unpack syntax.
but my suspicion is that the A16 will give me 16 separate array elementsYour intuition is very understandable, but wrong. Loose characters wouldn't be very useful, in general, so the perl implementers chose some other behavior that is more practically useful, as here.
so my template so far looks like this: '??A16CQQQS'Be very careful: 'Q' doesn't work on all platforms — not even on most platforms. Not all perls can even handle 64 bit integers, 53 bits is the most you can reliably use natively. You may want to look into Math::BigInt (with XS driver).
Also: 'S' is machine dependent. You may want to explicitly choose for 'n' (Big Endian) or 'v' (Little Endian AKA Intel) — which treats it as an unsigned number, BTW. You didn't specify your requirements here, but unsigned numbers can easily be converted to signed, if 2's complement (the usual case), by subtracting 2**16 if the number is 2**15 or higher.
unfortunately without any idea how to do the first 2 16 byte values (which need to remain binary, completely unchanged)Try 'a16' twice.
|
|---|