sub consensus { my $len = length($_[0]); # all strands are of one length, right? my @cons; # loop over the positions in the strands for my $i (0 .. $len - 1) { my %freq; my $max = 0; # loop over character $i in each of the strands for (map substr($_, $i, 1), @_) { $freq{$_}++; # save the max value $max = $freq{$_} if $freq{$_} > $max; } # store only those who occur the most times push @cons, [grep $freq{$_} == $max, keys %freq]; } return \@cons; }