my %count; $count{$_}++ foreach split //,$string; my $max = (sort {$a<=>$b} values %count)[-1]; print $max,' ',grep $count{$_} == $max,keys %count;