$ perl -e'$x="1 2 3 4 5 5 5 5 5 5"; $counts[$1]++ for $x=~/(\d)/g; print "$_ $c
ounts[$_]\n" foreach (0..$#counts)'
0
1
2
3
4
5 10
####
$ perl -e'$x="1 2 3 4 5 5 5 5 5 5"; $counts[$1]++ while $x=~/(\d)/g; print "$_
$counts[$_]\n" foreach (0..$#counts)'
0
1 1
2 1
3 1
4 1
5 6
####
$ perl -e'$x="1 2 3 4 5 5 5 5 5 5"; $counts[$_]++ for $x=~/(\d)/g; print "$_ $counts[$_]\n" foreach (0..$#counts)'
0
1 1
2 1
3 1
4 1
5 6
####
$ perl -e'$x="1 2 3 4 5 5 5 5 5 5"; $counts[$1]++ while $x=~/(\d)/g; print "$_ $counts[$_]\n" foreach (0..$#counts)'
0
1 1
2 1
3 1
4 1
5 6