in reply to Comparison effeciency

You may or may not consider this answer responsive, but... Have you tried throwing the word 'verilog' at CPAN ? You'll find 12 modules, including a choice of parsers, which seem to me to address your problem space and could reduce the amount of code you have to write. (Not that I have any experience of Verilog, much less the modules in question.) I've found it a good idea always to check CPAN first before embarking on a Perl project.

Apart from that, yes, use hashes as more advanced acolytes have advised.