while ($l=) { %count = (); $count{$1}++ while ($l =~ /(.)/g); $max = 0; $max_key; foreach (keys %count) { $max = $count{$_}, $max_key = $_ if ($count{$_} > $max); } push @consensus, $max_key; } print "@consensus\n"; __END__ ---ADGRCMNAAAPPRS ASAMNP-PRCM--MWQZ TYYCYLCKLKDUEAOLE $ perl cons.pl A - Y