in reply to search for a sequence of chars in a string

The left hand side of tr/// doesn't interpolate, and it also doesn't do what you want with multi-character strings. It's OK (and fast) for counting the number of a single type of character in a string, but not for a multi-character substring. You want:
## not this ## $n = ($string =~ tr/$search//); $n = () = $string =~ m/$search/g;
Update: But if your DNA sequence is really huge, loading it all into memory is probably very inefficient. You could use something like tachyon's approach given above, although it will probably miss matches that straddle a \n.

blokhead