[Chicago-talk] Odd HoH bug/problem

Shawn Carroll shawn.c.carroll at gmail.com
Tue Sep 11 12:58:07 PDT 2012

On Tue, Sep 11, 2012 at 2:17 PM, Randal L. Schwartz
<merlyn at stonehenge.com> wrote:
>>>>>> "Shawn" == Shawn Carroll <shawn.c.carroll at gmail.com> writes:
> Shawn> While I was debugging this I had say Dumper statements, to confirm the
> Shawn> data I was expecting was there, to dump the contents of %$types before
> Shawn> the while inner loop and everything would work as expected.  W/o it I
> Shawn> wouldn't get all my data.  The inputs all stayed the same between each
> Shawn> run and I am not doing anything funky w/ the data, just pulling out
> Shawn> what I need for output.  I even confirmed after the outer loop that
> Shawn> the data I wanted was still there.
> Dumper is walking your hashes, resetting your iterators.
> There is still something you're not revealing, because I'm puzzled.
> I suspect something *before* these loops is leaving the iterators
> mid-stride, which is why Dumper "fixes" it.  As a test, try this:
> my @dummy = keys %outer;
> while (my($k, $v) = each %outer) {
>   my @other_dummy = keys %$v;
>   while (my($k2, $v2) = each %$v) {
>     ..
>   }
> }
> If calling keys like this fixes it, then you have something before the
> loop that is leaving the iterator mid-stride.
> It's one of the reasons I rarely use each() any more.  That mid-stride
> iterator has bit me too many times.
That did the trick.  I don't see anything in my processing that would
make it leave the iterator but oh well.

Thank you for the help, sir.

More information about the Chicago-talk mailing list