perl中文本处理的例子:
open(FD,"input.txt")||die("can not open the file\n"); @line = <FD>; print @line; close(FD);
一下是输出每个单词的文本处理:
open(FD,"input.txt")||die("can not open the file\n"); $line = <FD>; @words = split' ',$line; foreach $word(@words){ print "$word \n"; } close(FD);
perl中求和的例子:
for($i=1;$i<100;$i++){ $sum += $i; } print "the sum is $sum \n";