use strict; use warnings; my $testinput = pack('C/a* a* a*', (pack 'C*', 1, 2), (pack 'v*', 3, 4), (pack 'l*', 5, 6)); print join(',', unpack('C/C* v2 l2', $testinput)), "\n"; # gives "1,2,3,4,5,6" which is ok, # but has the repeat factors for 'v' hardcoded my $repeat = unpack('C', $testinput); print join(',', unpack("C/C* v$repeat l$repeat", $testinput)), "\n"; # gives "1,2,3,4,5,6" which is ok, but uses two steps print join(',', unpack('C/C* @0 CXC /(x[C]) xX /v @0 CXC /((x[C])(x[v])) xX /l', $testinput)), "\n"; # gives "1,2,3,4,5,6" uses one step, but is a bit complex 1;