use strict; use Dumpvalue; my %test = ('level1' => { 'level2' => { 'level3' => { 'level4' => 1} } } ); #Dumpvalue->new->dumpValue(\%test); # when uncommented, this dump ## doesn't help the troubled while loops my $createtrouble = 1; if($createtrouble) { ################################################### # the woes of the troubled while loops further below is # really caused by the 'last's in these while loops while(my ($key1, $sdata) = each %test) { while(my ($key2, $stats) = each %$sdata) { last; } last; } } #Dumpvalue->new->dumpValue(\%test); # when uncommented, this dump ## mysteriously helps the troubled while loops print "Start print out now\n\n"; my $usewhile = 1; if($usewhile) { ################################################# # the troubled while loops while(my ($key1, $sdata) = each %test) { print "got in the first one!\n"; while(my ($key2, $stats) = each %$sdata) { print "got here! key2 is $key2\n"; } } } else { ################################################# # this one always works for my $key1 (keys %test) { my $sdata = $test{$key1}; print "got in the first one!\n"; for my $key2 (keys %$sdata) { print "got here! key2 is $key2\n"; } } }