|
From: Dan F. <da...@ha...> - 2007-02-02 22:18:09
|
David Landgren wrote: > There's nothing odd about this, it's standard Perl behaviour. > > each() stores its state on the hash, and returns the next element each > (heh) time it is called until all the keys have been visited, at which > point it returns undef. This can have surprising consequences. If you > call each() from different areas in the code upon the same hash: the > next call to each() returns the next item in from the hash's point of > view, not the caller's point of view. > > Its simply because im not a regular perl coder then. I assumed the function would operate on a copy of the hash, as it is with most other languages. Took me quite a while to figure out what was going on and then fix it with the keys %hash :) |