my %c; $string =~ tr[ACGT][N]c; $c{ substr $string, $_, 1 }[ $_ ]++ for 0 .. length( $string )-1;