http://www.perlmonks.org?node_id=177551


in reply to Array statistics

To count the occurrance of things in your array:

my @array = ('foo', 'foo', 'bar', 'foo', 'bar', 'baz'); my %count; $count{$_}++ for @array; for(sort(keys(%count))) { print "$_: $count{$_}\n"; }

I'm sure you can work out how to then calculate the percentages.