in reply to Re: (jeffa) Re: (s)coping with foreach
in thread (s)coping with foreach

...the last value of the index variable will tell you when you left...
then try this:
my @numbers = (0..9); foreach my $i (0..$#numbers) { print $numbers[$i]; stopped($i),last if $i > 4; } sub stopped { my $index = shift; print "Stopped at $index\n"; }

Jeff

R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--