in reply to Re: for loop localisation bug?
in thread for loop localisation bug?

Thanks cees. That's what I was missing. I'm amazed I never encountered this before, but I guess it just shows how infrequently you need to know at what point a for loop exits.

It's no problem to re-code this as a c-style for, or any number of other ways, but it did surprise me.

perl -le" my $n; for( $n=0; $n <=10; $n++ ){ print $n; last if $n == 5 + }; print '$n= ', $n;" 0 1 2 3 4 5 $n= 5

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!