my $Str = "AAAA001BBBB001CCCC000DDDD023EEEE012"; my %H; while($Str) { my $s = substr($Str, 0, 4, ''); my $i = substr($Str, 0, 3, ''); %H{$s} = $i; }
[download]
Output: AAAA -> 001 BBBB -> 001 CCCC -> 000 DDDD -> 023 EEEE -> 012
[download]