![]() |
|
laziness, impatience, and hubris | |
PerlMonks |
mystery re each + lastby inq123 (Sexton) |
on Sep 28, 2005 at 15:05 UTC ( #495783=perlquestion: print w/replies, xml ) | Need Help?? |
inq123 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, yesterday I got a strange bug that took a while to fix. It also took a while to trace down the bug enough to recreate it in the short script below (original script was too long to post). Basically the symptom is that first I create a hash of hash of hash, then use a while(my ($key, $value) = each %hash) to loop through it, then inside the while loops, use 'last;' to break them. After that, create a second set of those while loops, and the problem is, the 2nd set of the while loops won't be entered. If I don't use 'last;', or if I use 'for my $key (keys %hash)', or if I use a dump immediately before the 2nd set of the while loops, the problem would be "fixed". But I want to understand why the 2nd set of while loops do not work in the first place. Anyone could help? BTW I tested it on Perl on UNIX and Windows, 5.6.1 - 5.8.5. Without further ado, here's the script:
2005-10-01 Retitled by planetscape, as per Monastery guidelines
Back to
Seekers of Perl Wisdom
|
|