use strict; my %hash; while () { chomp; my @chars = split ''; for my $char (@chars) { # use the next line if case doesn't matter # $hash{lc $char}++; $hash{$char}++; } print join " ", @chars, "\n"; } my $consensus = ''; for (sort keys %hash) { $consensus = $_ if $hash{$_} > $hash{$consensus}; print "\$hash{$_}: $hash{$_}\n"; } print "\nChar: '$consensus' has the highest count: $hash{$consensus}!\n"; __DATA__ aAabbbbcdDeeeeEEefFFffffffffffff zzzzzzzxxxxxxxxxyyYyg