Obvious question first: Why re-invent the wheel?
ht://Dig might do what you need.
Other than that, go by logic. If you have to search for something (often), create a database of possible matches in certain intervals. That way you don't have to open all the files every time.
And what do you not like about Perl? It was written for effective text processing, so it might just be the right tool for a job like this.