in reply to Re: To count letters (%identity) in DNA alignment
in thread To count letters (%identity) in DNA alignment

Minor nit-pick -- I'd want to include some defensive programming, because with 10K+ records to go through, there's (almost) no such thing as being too careful.

And while we're at it, if we're ready to deal with unsuitable data, might as well, point out when it happens:

... my $bad_count = 0; while (<...>) { chomp; my ( $name, $seq ) = split; unless ( $seq and $seq =~ /^[ACGT]+$/ ) { $bad_count++; next; } ... } warn "Input file had $bad_count unusable lines\n"; ...
For that matter, if all the records are supposed to have the same number of letters, add that as part of the conditional.