in reply to Re: Quick way to find the letter with the most occurences in a string
in thread Quick way to find the letter with the most occurences in a string

Modified to handle cases with several characters with the maximal number of occurences:
my %count; $count{$_}++ foreach split //,$string; my $max = (sort {$a<=>$b} values %count)[-1]; print $max,' ',grep $count{$_} == $max,keys %count;
  • Comment on Re^2: Quick way to find the letter with the most occurences in a string
  • Download Code