my %hash; my @a=(1,2,2,3,3,3,3,3,1); $hash{$_}++ for (@a); print "$_\t$hash{$_}\n" for keys %hash;