in reply to Unpacking struct
Bitwise operations may be your best choice. There are no 24-, 6-, or 26-bit types in unpack's formats, and vec demands its chunks be a power of two bits wide and aligned. Here is one way to do it, unpacking to three ints and doing the bit operations.
That's not quite as unportable as it looks, but it's still on the edge.$fh->read(my $buf, 12); my ($var1, $var2, @raw) = unpack 's s L2' $buf; my ($var3,$var4) = map { ($_ >> 8, $_ & 0xff) } $raw[0]; my ($var5,$var6) = map { ($_ >> 26, $_ & 0x3fffffff) } $raw[1];
Update: Differs from Stevie-O's by bit order of the C struct. I'm not sure which is correct, so I'd bet on his. Adjust to what works :-)
After Compline,
Zaxo
|
|---|