Perl next statement
The Perl next statement is used to stop executing statements between the next statement of the next statement of the next statement and the end of the loop body identifier, to execute the continue statement block, and then to return to the beginning of the loop body to start the next loop.
Grammar
The syntax format looks like this:
next [ LABEL ];
WHERE LABEL is optional, if LABEL is not specified, the next statement returns to the beginning of the loop body to begin the next loop.
Instance
#!/usr/bin/perl $a = 10; while( $a < 20 ){ if( $a == 15) { # 跳出迭代 $a = $a + 1; next; } print "a 的值为: $a\n"; $a = $a + 1; }
The above procedure is performed and the output is:
a 的值为: 10 a 的值为: 11 a 的值为: 12 a 的值为: 13 a 的值为: 14 a 的值为: 16 a 的值为: 17 a 的值为: 18 a 的值为: 19