我刚开始学习 Perl 脚本语言,有一个问题。
在 Perl 中,具有 continue
的逻辑原因是什么?与 while
一起阻止工作和 do while
循环,但不是 for
环形?
最佳答案
来自 http://perldoc.perl.org/functions/continue.html
If there is a continue BLOCK attached to a BLOCK (typically in a while or foreach ), it is always executed just before the conditional is about to be evaluated again, just like the third part of a for loop in C.
意思是在
for
循环,第三个参数是 continue 表达式,例如for (initialization; condition; continue)
,因此不需要。另一方面,如果您使用 for
在 foreach
样式,例如:for (0 .. 10) {
print "$i\n";
} continue { $i++ }
这将是可以接受的。
关于Perl 编程 : continue block,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5963286/