http://www.perlmonks.org?node_id=1025292

cls33 has asked for the wisdom of the Perl Monks concerning the following question:

I have a program where I need to check to see if a variable is equal to any one of a list of 1000+ values. Since I'll need to check this several times over the course of the program's execution, I'm wonder what the most efficient way to do this is.

My first though is to read all 1000+ of these values into a hash on startup (there is no DB backing this) where the values I'm checking against are the keys and then just using something like 1 for the value. Then when I need to do a see if the variable is one of these values, just check the hash using the current value of the variable as the key and see if I get anything "true" back...

Sound like I'm on the right track? Or is there a "better" way?