last LABEL last |
不是一个函数。last关键字立即使循环当前迭代,成为最后一个循环控制语句。没有进一步的语句被执行,并结束循环。如果指定LABEL,然后它丢弃循环的识别LABEL,而不是目前的封闭循环。
Nothing
试试下面的例子:
#!/usr/bin/perl $count = 0; while( 1 ){ $count = $count + 1; if( $count > 4 ){ print "Going to exist out of the loop\n"; last; }else{ print "Count is $count\n"; } } print "Out of the loop\n"; It will produce foillowing result: #by www.gitbook.net Count is 1 Count is 2 Count is 3 Count is 4 Going to exist out of the loop Out of the loop