學無止盡
my $result = 1; for (my $num = 1; $num <= 10; $num = $num + 1) { $result *= $num; }
for my $num (1...10) { # 這就是表示$num從1到10
print $num; } 這其實可以寫成: for (1...10) { # $_ 經常被拿來作為迴圈的預設變數 print $_; } 更簡化的寫法: print for (1...10);
perl | for
JohnChen
JohnChen.twm@gmail.com