print for unpack 'n N Z* C Z* C', "\x01\x01\x04\x03\x02\x01The first string\0\xffThe second string\0\xff";; 257 67305985 The first string 255 The second string 255 #### package This::Packet; sub new { my( $class, $bufRef ) = @_; my( $ping, $rate, $name, $ctpos, $clantag, $isbot ) = unpack 'n N Z* C Z* C', $$bufRef; my $nPacket = 2 + 4 + length( $name )+ 1 + 1 ## string + null + ctpos + length( $clantag ) + 1 + 1; ## string + null + IsBot # ... validate substr( $$bufRef, 0, $nPacket, '' ); ## remove this packet from the buffer return bless { ping => $ping, rate => $rate, name => $name, cpos => $ctpos, clantag => $clantag, isBot => $isBot, }, $class; } ## accessors go here