in reply to Parsing protocol data: unpack and bytes
You're making that much too complicated. To unpack the structure listed, you only need do something like:
my( $ping, $rate, $name, $tagP, $tag, $isBot ) = unpack 'S N Z32 A1 Z32 A1', $buffer;
You might need to vary that somewhat depending upon the sending system. For example you might need V instead of N if the sending system is little-endian. Or you might need to include some padding.
But work with Perl's facilities (eg.unpack), rather than fighting them as your code above is doing, and life gets much easier, clearer and quicker.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing protocol data: unpack and bytes
by dichtfux (Sexton) on Dec 10, 2007 at 17:56 UTC | |
by ikegami (Patriarch) on Dec 10, 2007 at 18:18 UTC | |
by BrowserUk (Patriarch) on Dec 10, 2007 at 19:23 UTC | |
by dichtfux (Sexton) on Dec 10, 2007 at 20:46 UTC | |
by BrowserUk (Patriarch) on Dec 10, 2007 at 23:30 UTC | |
by tye (Sage) on Dec 10, 2007 at 23:54 UTC |