If the source is one long DNA string (and not just the 20 or so characters you describe), neither grep nor perl is going to do this for you.
The reason is that both models work at the line level - read a line, check for match, move onto next line.
If you have one long DNS sequence, it will read in the entire sequence as one 'line' and report if there's any match - anywhere in the string.
Assuming you can read the entire sequence into RAM, there's likely to be at least one match somewhere in the string, but both models will simply tell you there's a match, not where it is, nor if there's more than one match in the sequence.
You'd have to change the code to something that reads a few bytes at a time, checks for matches, moves along a byte, check for more matches, etc, etc. ad infinitum.
In short, there's a reason why there are commercial gene sequencing programs costing $$$$$s.