I spent a small amount of time debugging a problem in a script I was modifying this morning as a while loop with each seemed to loop forever:
which iterates forever. I re-read the pod for each and still didn't get it but narrowed it down to the call to Dumper on %x. Thinking Dumper was iterating over %x I tried copying %x to %y and Dumper(%y) but that iterated forever too. Strangly changing it to:
worked fine and yet the pod for each says the same iterator is used for each, keys and values.
On #perl-help ilmari told me keys and values reset the iterator, exhaust it and reset it again whereas each does not and using a hash in list context will use the iterator internally and hence reset it - hence copying the hash to another hash resets the iterator. I've used Perl a long time and never come across this (although I rarely use each and probably won't use it much now anyway) but I was surprised this was not mentioned in the pod for each.
If I'm still misunderstanding this I'd happy to be put right.