in reply to Re^2: The Anomalous each()
in thread The Anomalous each()

Its not a work-around so much as it is how you've always been supposed to use it. Its not a bug because its designed that way. Or at least isn't *called* a bug. Its pretty dumb behaviour and it makes it easy to make mistakes. The only time I'd ever use each() is on hashes which might have large numbers of keys. It'd be potentially wasteful or fatal to do a loop over keys(%hash) on an especially large hash. When that's possible, then you just have to bite the bullet, use each() and do it safely.

Replies are listed 'Best First'.
Re^4: The Anomalous each()
by jdhedden (Deacon) on Nov 18, 2005 at 20:54 UTC
    It's not a work-around so much as it is how you've always been supposed to use it.
    Where is it documented that you need to be proactively cautious when using each() by proceeding it with keys()? Or to make sure you avoid using each() if your hash may be touched by other code inside you loop?

    The perlfunc entry tells you there's one iterator, true, but doesn't give you any insight into the potential pitfalls that may lead to. That was the purpose of my post.