xuyangus 发表于 2017-5-19 09:45:40

perl for and foreach explained with example

  


# 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;
}
 
页: [1]
查看完整版本: perl for and foreach explained with example