|
|
last, next, redo, in Perl - Perl
|
Views : 282
|
|
Tagged in : Perl
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
last, next, redo, in Perl
The last statement is used to break out of a block loop. In the following example, if the 'somecondition' expression is true, the 'dothesestatements' is executed the first time along with last. The loop is immediately exited and the 'morestuff' doesn't get executed.
while (something) {
statements;
if (somecondition) {
dothesestatments;
last;
}
morestuff;
}
# last jumps to here
The next statement is used to break from a inner, jump to the end of the loop, and continue the loop.
while (something) {
statements;
if (somecondition) {
dothesestatements;
next;
}
morestuff;
# next jumps to here & continues loop
}
The redo statement is used to jump to the top of the loop without re-evulating the control expression.
while (something) {
# redo jumps to here & continues loop
statements;
if (somecondition) {
dothesestatements;
redo;
}
morestuff;
}
|
|
By Geethalakshmi, On - 2010-09-17 |
|
|
|