我正在尝试编写一个脚本,该脚本将计算并删除文件中的空行并将更改保存在新文件中:
if (@ARGV != 2) {
print "Usage: $0 infile outfile\n";
exit;
}
$infile = @ARGV[0];
$outfile = @ARGV[1];
open($old, "<$infile");
open($new, ">$outfile");
@mass = <$old>;
foreach $newc(@mass) {
$counter++;
if ($_ =~ /^$/) {
print "blank line found in $old at line number $counter\n";
print $new;
}
}
close($new);
close($old);
但它不起作用。我哪里错了?