in reply to while loop question
You can always wrap your while loop in a simple block with a label and use last LABEL
So something like this :-
use v5.14; use warnings; my @l = (0..5); sub test { my ($match) = @_; LOOP: { for my $v (@l) { if ($v == $match) { say "found"; last LOOP; } } # fell off the bottom say "not found"; } } test(4); # found test(7); # not found
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: while loop question
by Freezer (Sexton) on Sep 06, 2012 at 13:34 UTC | |
by RichardK (Parson) on Sep 06, 2012 at 14:56 UTC |