use Data::Dumper; $Data::Dumper::Sortkeys=1; my @my_array=('a','-2','3','b','0xffff','c','2','b','a','4','a','a','200'); my %counts; $counts{$_}++ for @my_array; print Dumper(\%counts);