in reply to performance issues
Think some more about this file.
Is the file only rarely changed? Or, is it changed much more rarely than it is searched? Or, at least, are the changes, when they come, relatively small?
If so, you could benefit enormously by importing the file into a database once, and then letting the database do the heavy lifting of indexing and searching.
In Section
Seekers of Perl Wisdom