On Mon, Nov 03, 2003 at 02:06:01PM +0000, Tim Bunce wrote: > A separate issue with C<each> is that code using it generally assumes > that the has itterator is at the start of the hash. If it's not > (because an C<each> loop somewhere terminated early, for example) > then some items of the hash will be skipped. A very hard to find bug. > Its cheap to reset an itterator, just do > keys %foo; > before the C<each> loop.
Similarly, I had a nasty bug in Class::DBI for a while where a reference to the hash being iterated over was being passed off to another method inside that loop. When the method being called did anything with the hash it reset the loop ... Tony