我有一个简单的Perl脚本,可以逐行读取文件。代码如下。我想显示两行并中断循环。但它不起作用。bug在哪里?
$file='SnPmaster.txt';
open(INFO, $file) or die("Could not open file.");
$count = 0;
foreach $line (<INFO>) {
print $line;
if ($++counter == 2){
last;
}
}
close(INFO);
https://stackoverflow.com/questions/4505381
复制相似问题