use strict; use warnings; my $testinput = pack('C/a* a* a*', (pack 'C*', 1, 2), (pack 'v*', 3, 4), (pack 'v*', 5, 6)); print join(',', unpack('C/C* v2 v2', $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 v$repeat", $testinput)), "\n"; # gives "1,2,3,4,5,6" which is ok, but uses two steps