http://qs321.pair.com?node_id=1212584


in reply to Perlish approach to parsing a binary blob

If you don't mind having a structure that stores something else at the beginning, you can use one unpack and then change the structure in place. It seems almost 10% faster on my machine:
my $data = "1ABCD2EFGH3IJKL4MNOP5QRST6UVWX"; my $entry_size = 5; my $a_size = $entry_size - 1; my @out = unpack "(CA$a_size)*", $data; push @out, [ splice @out, 0, 2 ] for 1 .. @out / 2;

Update: BrowserUk's solution seems even faster, adding again almost 10%.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,