空行をカウントしてファイルから消去し、変更を新しいファイルに保存するスクリプトを作成しようとしています。
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);
しかし、それは機能していません。どこが間違っていますか?