in reply to Re: Hash search yields unexpected results
in thread Hash search yields unexpected results

The iteration over a hash with each is not only inefficient, but also wrong. The reason is that the iterations aren't completed, so the next time the while-loop is entered, the the iteration continues where it left off before.

That's because the state of the each-iterator is not tied to a lexical scope, but rather to the hash itself.