$ 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