Perl last關鍵字 - 極客書

文章推薦指數: 80 %
投票人數:10人

定義和用法. 不是一個函數。

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



請為這篇文章評分?