We don't bite newbies here... much | |
PerlMonks |
Spot the bugby tlm (Prior) |
on Dec 21, 2005 at 00:59 UTC ( [id://518216]=perlmeditation: print w/replies, xml ) | Need Help?? |
I know variants of the following bug have been discussed in the Monastery recently, but I didn't find this particular one. My apologies in advance if I missed it. Spot the bug:
BTW, there's nothing arcane about this bug. It's vanilla Perl, but it's easy to miss. This is yet another guise of the ol' each bug. The problem is that if the function is called with the same arguments twice, and if during the first call the while is exited due to the result of sometest , then in the second call to the foo, the iteration will not begin in the same place as it did in the first call. Conceivably this could be the desired behavior, but I bet that in most cases it isn't. To fix it, use keys before the loop:
Update: The original title of this thread ("Buglet") was confusing, so, by popular demand, I changed it. I hope the new title is an improvement. the lowliest monk
Back to
Meditations
|
|