# file:
# for_foreach.pl
# description:
# this is the file to test semantic of the for and foreach construct
#
# conclusion:
# for is a synonym of foreach
# for also support the count type of iteration
#
use strict;
for (101 .. 200) { print; }
foreach (101 .. 200) { print; }
for (my $i = 0; $i < 100; ++$i) {
print $i;
}
本文通过具体示例展示了Perl中for和foreach循环的使用方法及两者之间的等价性,并且介绍了计数型迭代的应用。
736

被折叠的 条评论
为什么被折叠?



