Perl next statement
The Perl next statement is used to stop executing statements from the statement following the next statement up to the end-of-loop-body identifier, then transfer execution to the continue block, and then return to the beginning of the loop body to start the next iteration.
Syntax
The syntax format is as follows:
next [ LABEL ];
LABEL is optional. If LABEL is not specified, the next statement will return to the beginning of the loop body and start the next iteration.
Example
#!/usr/bin/perl
$a = 10;
while( $a < 20 ){
if( $a == 15)
{
# Skip this iteration
$a = $a + 1;
next;
}
print "The value of a is:$a\n";
$a = $a + 1;
}
Executing the above program produces the following output:
a 的值为: 10 a 的值为: 11 a 的值为: 12 a 的值为: 13 a 的值为: 14 a 的值为: 16 a 的值为: 17 a 的值为: 18 a 的值为: 19Other extensions
Perl loops