note
choroba
If you don't mind having a structure that stores something else at the beginning, you can use one [doc://unpack] and then change the structure in place. It seems almost 10% faster on my machine:
<c>
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;
</c><P>
<B>Update:</B> [BrowserUk]'s solution seems even faster, adding again almost 10%.<P>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-832495">
<c>($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,</c>
</div></div><!-- Wiki2Monks {"version":1.1416} -->
1212579
1212579