Perl Labeled blocks

by Geethalakshmi 2010-09-17 14:04:40

Perl Labeled blocks


Labeled blocks work similiar to 'goto' in other languages. It is recommended that the label name is in all upper case and only use letters or numbers. Also use a name that isn't or won't ever be used as reserved word, i.e. 'print' would not be a legal name to use for label. The name is always followed by a colon.

SOMELABEL: while (condition) {
statements;
if (somethingelse) {
otherstatements;
last SOMELABEL;
}
}

Tagged in:

979
like
0
dislike
0
mail
flag

You must LOGIN to add comments