[Chicago-talk] Odd HoH bug/problem

Shawn Carroll shawn.c.carroll at gmail.com
Tue Sep 11 11:36:49 PDT 2012

I hit send to soon...

On Tue, Sep 11, 2012 at 1:33 PM, Shawn Carroll
<shawn.c.carroll at gmail.com> wrote:
> Let me preface this by saying that I have not been able to reproduce
> this problem in a smaller program and I understand that this makes it
> less useful for identifying the root cause.
> In my program I create a HoHoH and need to step through in a final
> sub.  As I've done many times in the past I use a while block and use
> each to assign the key & value to loop variables.
>         while( my ($id, $types) =  each %data )
>         {
>                 say "$id => $types";
>                 while ( my ($type, $data) = each %{ $types })
>                 {
                       say $type
                       # processData

The first say confirms that every $types is a hash but the second
while loop doesn't process every $types.  If I replace the second
while with a foreach my $type (keys %{$types}) loop everything works
as expected.

Am I missing something here?  I am confused.

More information about the Chicago-talk mailing list