my ($value) = unpack ("C4", $packet); and then treat $value as any number, i.e. $field = ($value & 0x80000000) >> 24; ?I think you want to unpack a 4-byte integer there. So try N or V, not C ! I think you don't grasp what unpack is doing. You have 4 bytes in your packet, so you don't say "these are 4 bytes", you say what you want to produce from them. The length and encoding is implied by that. so, you say "interpret the next bytes as a 4-byte 2's complement integer in network byte order", or somesuch.
In reply to Re: Mysteries of unpack
by John M. Dlugosz
in thread Mysteries of unpack
by atypic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |