I'm looping through the contents of an array.
Before each iteration of the loop is completed, I want a couple of things done (increment a count, print some debug info, and a few other things). There are a number of conditions that cause the loop to move on to the next one early so my though is to put these into a subroutine and call that. However, one of these things is:
if ($x > $stop) {
last;
} elsif ($y ne $text) {
foobar();
} else {
next;
}
So of course I get the warning "Exiting subroutine via last" (or next)
Is there a good way of doing this without having to put that snippet of code into every place where I need to move the loop forward?
Update:
hexcoder with the
continue block is exactly what I need. Thanks!