本文主要是介绍perl last 退出循环问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
LINE: while (<STDIN>) { last LINE if /^$/; # exit when done with header #... };jrhmpt01:/root# cat w.pl while (1==1){for ($i = 1;$i <= 10;$i++){ #从1数到10print "1----------\$i is $i\n";if ($i == 7){print "2-------\$i is $i\n";last;}}};print "xxxxxxxxxxxxxx\n";1----------$i is 11----------$i is 21----------$i is 31----------$i is 41----------$i is 51----------$i is 61----------$i is 72-------$i is 71----------$i is 11----------$i is 21----------$i is 31----------$i is 41----------$i is 51----------$i is 61----------$i is 72-------$i is 71----------$i is 11----------$i is 21----------$i is 31----------$i is 41----------$i is 51----------$i is 61----------$i is 72-------$i is 7这里的last 是退出了if的循环,而没有退出while 循环jrhmpt01:/root# cat w.pl $i=1;while (1==1){$i++;print "1----------\$i is $i\n";if ($i == 7){print "2-------\$i is $i\n";last;}};print "xxxxxxxxxxxxxx\n";jrhmpt01:/root# perl w.pl 1----------$i is 21----------$i is 31----------$i is 41----------$i is 51----------$i is 61----------$i is 72-------$i is 7xxxxxxxxxxxxxx此时last 退出while 循环
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
这篇关于perl last 退出循环问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!