in reply to New behavior of 'each' with respect to references
My guess is that this is intended to facilitate recursive traversal of nested data-structures.
As each can operate on arrays (and array refs) as well as hashes, it potentially allows the same loop to traverse both types of structure without having to differentiate between hashrefs and arrayrefs.
That said, you still have to check you have a ref; that it is a ref to one of the two types and not a scalar etc. It doesn't immediately shout of any great reduction in code complexity.
Add in the fact that it must be an unblessed ref which presumably excludes tied hashes and objects exporting hash or array like interfaces--which seems unnecessarially arbitrary--and it is quite hard to see any great benefit from the change.
May be it is there, but it doesn't leap off the page at you.
|
|---|