“5 gigabytes” is not what one would consider a particularly “large” file anymore. Simply create a database ... SQLite would be an excellent choice since it requires no server and runs everywhere ... and load the information into it using any one of several existing SQLite tools.
I suspect that you may have persuaded yourself that “I must write a (Perl) program to do this,” when in fact you probably don’t have to write anything at all. Load your reference data in one table, and your search into another, and do an INNER JOIN. Mission accomplished.
“To a hammer, everything is a nail.”