in reply to Iterating over string
This gathers the same information (ie. counts character at position in the string), and runs roughly 40 times faster.
(Faster still if you don't need the tr///).
my %c; $string =~ tr[ACGT][N]c; $c{ substr $string, $_, 1 }[ $_ ]++ for 0 .. length( $string )-1;
|
|---|