Building a hash is slower than scanning the array.
Accessing a hash many times is faster than scanning the array many times.
At some fairly small fixed number, building the hash is worthwhile. That number varies with OS, version of Perl, and what parameters Perl was built with. I tested it once at 7, but that is probably not true any more.
Cheers,
Ben