【发布时间】:2013-07-11 20:22:24
【问题描述】:
我正在尝试使用以下代码读取文件中的行。但是这段代码的结果是打印与文档行相同的行。
open (file_to_rand, "./files/file07.txt") or die "Could not open file";
foreach $line (<file_to_rand>) {
push(@array,$line);
}
close(file_to_rand);
这段代码有什么问题?
【问题讨论】:
-
那么问题是什么?
-
不,这段代码的“结果”是不打印任何东西。这段代码中唯一可能输出任何东西的是
die。另外,"to print the same line as lines the document has"这句话是语法错误,没有任何意义。