in reply to What's happening to this hash?

each is used under the hood to provide the result from keys with the result that the iterator used by each is reset. Your hash has only one entry so in the first case you only get one iteration of the while "if" (bizare construction btw!) before each hits the end of the list. In the second case you keep resetting the iterator by using keys so the if/while always sees a true value because it always accesses the first element in the hash.


DWIM is Perl's answer to Gödel