In a loop, I have several conditions and if the condition is not satisfied, I exit out of the loop using last syntax.
while (condition) {
if (possibility 1) {
...
last;
}
if (possibility 2) {
if (possibility 3) {
...
last;
}
...
last;
}
}
After I come out of the loop, I need to know whether I used last to exit, or the condition just did not hold true any more. One way of doing that is to write a if statement that negates all the possibilities.
I am looking for some easier/more elegant way to do this.
Is there some Perl variable that stores the information that we exited out of the loop due to last? Or do I need to maintain such a variable myself?
last. A more concrete example would allow us to give better advice.