in reply to further subdivision of unpack result
Why are you converting to bits only then to have to convert back to bytes?
Reading between the lines of your post, you could use this to get at the bytes:
($id, @bytes) = unpack ("A16 x72 C*", $data);
and then just access the them via the array.
But then, looking at the way you are numbering your 4 bytes: (byte2, byte1, byte4, byte3) it seems likely that each group of 4 bytes is actually a little endian 32-bit value. In which case, you can skip the bytes step also and do:
($id, @dwords) = unpack ("A16 x72 (L<)*", $data);
It's a lot simpler to use the built-in facilities :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: further subdivision of unpack result
by ikegami (Patriarch) on Apr 13, 2011 at 04:40 UTC |