Perl next statement
Perl next statement is used to stop the execution of the next statement from the next statement to start the loop between the end of the statement identifier, turn to continue the implementation of the statement block and then back to the beginning of the loop body begin the next cycle.
grammar
The syntax is as follows:
next [ LABEL ];
Where LABEL is optional, if not specified LABEL, next statement will return to the beginning of the loop body begin the next cycle.
Examples
#!/usr/bin/perl $a = 10; while( $a < 20 ){ if( $a == 15) { # 跳出迭代 $a = $a + 1; next; } print "a 的值为: $a\n"; $a = $a + 1; }
The above program, the output is:
a 的值为: 10 a 的值为: 11 a 的值为: 12 a 的值为: 13 a 的值为: 14 a 的值为: 16 a 的值为: 17 a 的值为: 18 a 的值为: 19