in reply to overload + each() bug?

That does not look like a bug to me. You call as_hash for each key and recreate the hash on each iteration. Rewrite as_hash like this fix this behavior.
{ my $xxx = { 'key1' => 'value1', 'key2' => 'value2' }; sub as_hash { return $xxx; } }
Boris

Replies are listed 'Best First'.
Re^2: overload + each() bug
by dragonchild (Archbishop) on Nov 17, 2005 at 16:07 UTC
    To elaborate, the problem is that the hash is recreated each time, which means the internal iterator is also recreated each time. The same behavior will show up for keys() and values(), as well.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      The same behavior will show up for keys() and values(), as well.
      Incorrect. keys() and values() are not iterators. They return lists composed of data from the hash argument. When used in a 'for' loop, they only get called once.
      Remember: There's always one more bug.
Re^2: overload + each() bug
by VSarkiss (Monsignor) on Nov 17, 2005 at 16:10 UTC