According to the perl manual for for last
(http://perldoc.perl.org/functions/last.html), last
can't be used to break out of do {}
loops, but it doesn't mention an alternative. The script I'm maintaining has this structure:
do {
...
if (...)
{
...
last;
}
} while (...);
and I'm pretty sure he wants to go to the end of the loop, but its actually exiting the current subroutine, so I need to either change the last
or refactor the whole loop if there is a better way that someone can recommend.
do BLOCK while (EXPR)
is funny in that do is not really a loop structure. So, last, next, and redo are not supposed to be used there. Get rid of the last and adjust the EXPR to evaluate false when that situation is found.
Also, turn on strict, which should give you at least a warning here.