Chinaunix首页 | 论坛 | 博客
  • 博客访问: 988060
  • 博文数量: 150
  • 博客积分: 3017
  • 博客等级: 少校
  • 技术积分: 3829
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-19 14:40
个人简介

Now in Baidu WISE team

文章分类

全部博文(150)

文章存档

2014年(8)

2013年(31)

2012年(111)

分类: Python/Ruby

2012-06-05 20:11:28

for (1..5){
 print "Now working on $_ \n";
 my $i = 1;
 do{
  if($i == 5){
   print "I jumped out by i = 5\n";
   last;
  }
  $i++;
 }while($i<10);
}
 
代码中last本来是为了跳出 do-while循环。 按照我的理解 for循环依然执行5次。 但是实际效果,for循环只执行了1次。 last跳出的时候直接出了for.这是为啥?
此问题先记录在这,等找出答案了补充。
 
结果如下:
Now woring on 1
I jumped out by i = 5
阅读(4931) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~