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--
In reply to (jeffa) 3Re: (s)coping with foreach
by jeffa
in thread (s)coping with foreach
by greenFox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |