Perl last關鍵字 - 極客書
文章推薦指數: 80 %
定義和用法. 不是一個函數。
last關鍵字立即使循環當前迭代,成為最後一個循環控製語句。
冇有進一步的語句被執行,並結束循環。
如果指定LABEL,然後它丟棄循環的識 ...
全部+
Java
MySQL
教學目錄
+發布教學
當前位置:首頁»Perl»Perllast關鍵字
Perl教學
Perl高級教學
Perl參考文獻
Perl教學
Perl簡介
Perl語法概述
Perl變量
Perl標量
Perl數組
Perl哈希
Perl特殊變量
Perl條件語句
Perl循環
Perl內置操作符
Perl文件I/O
Perl正則表達式
Perl子例程
Perl格式-報表
Perl錯誤處理
Perl編程標準
Perllast關鍵字
perllast關鍵字學習例子,last實例代碼,教學等
語法
lastLABEL
last
定義和用法
不是一個函數。
last關鍵字立即使循環當前迭代,成為最後一個循環控製語句。
冇有進一步的語句被執行,並結束循環。
如果指定LABEL,然後它丟棄循環的識彆LABEL,而不是目前的封閉循環。
返回值
Nothing
例子
試試下麵的例子:
#!/usr/bin/perl
$count=0;
while(1){
$count=$count+1;
if($count>4){
print"Goingtoexistoutoftheloop\n";
last;
}else{
print"Countis$count\n";
}
}
print"Outoftheloop\n";Itwillproducefoillowingresult:
#bywww.gitbook.net
Countis1
Countis2
Countis3
Countis4
Goingtoexistoutoftheloop
Outoftheloop
延伸文章資訊
- 1Perl last 語句 - HTML Tutorial
Perl last 語句用於退出循環語句塊,從而結束循環,last語句之後的語句不再執行,continue語句塊也不再執行。 語法. 語法格式如下所示: last [LABEL];. 流程圖. ...
- 2last - Perldoc Browser
If the LABEL is omitted, the command refers to the innermost enclosing loop. The last EXPR form, ...
- 3What does "last" do in Perl? - Stack Overflow
Available uses for last command: ... According to Perl's documentation: The last command is like ...
- 4Perl last Statement
The Perl last statement is used inside a loop to exit the loop immediately. The last statement is...
- 5Perl last Function - Tutorialspoint
Perl last Function, This is not a function. The last keyword is a loop-control statement that imm...