in reply to Re^4: grep { } positional number of element
in thread grep { } positional number of element

> Much of the time we can be sure of that I think.

Only if you don't call any other routines from any other module while using each.

I seem to remember that one of the dumper modules messed with the each counter.

Similarly if you export your sub and the data structure is passed as variable. Than the importing code could get into trouble using each.

Otherwise you need to copy the hash/array beforehand.

(all of this would be much easier if there was a way to localize the internal counter)

update

in short, each X is only safe if X is never passed around.

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery