in reply to fast hash search

In general, either a brute-force search which uses a loop of some kind, whether foreach, while, map, grep, etc. that checks each one until you find it; or

Create an index with the thing you are looking up as the hash key. In this case, loop over all the entries once, building another hash such that $index{string}=key2. Then reference that index as many times as needed, quickly.

If the reverse mapping is not unique, than things are more difficult, but you get the idea.