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 :)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: further subdivision of unpack result
by ikegami (Patriarch) on Apr 13, 2011 at 04:40 UTC
    Little-endian isn't 2,1,4,3, it's 4,3,2,1.
    >perl -E"say for unpack 'H*', pack 'L<', 0x11223344" 44332211