You’re right, using a hash is, in general, a better approach than using an array, because a hash is, by its nature, optimised for lookup.
There’s a useful discussion of the various options in perlfaq4#How-can-I-tell-whether-a-certain-element-is-contained-in-a-list-or-array?
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^2: The most efficient way for searching for an element in an array?
by Athanasius
in thread The most efficient way for searching for an element in an array?
by Ppeoc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |