# Arguments are datum length (5, 6, 7, or 8) and stream data (whose # length must be a multiple of the datum length) sub unpack_stream { my ( $length, $stream ) = @_; $length ||= 5; $length >= 5 and $length <= 8 or die "Length $length must be between 5 and 8 inclusive\n"; my $pad = pack 'C*', ( 0 ) x ( 8 - $length ); return map { unpack 'Q<', "$_$pad" } unpack "(a$length)*", $stream; }