Perl last statement
The Perl last statement is used to exit the loop statement block, thereby ending the loop, the statement after the last statement is no longer executed, and the continue statement block is no longer executed.
Grammar
The syntax format looks like this:
last [LABEL];
Flow chart
Instance
#!/usr/bin/perl $a = 10; while( $a < 20 ){ if( $a == 15) { # 退出循环 $a = $a + 1; last; } 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