我需要编写一个脚本来查看文件并用普通括号替换任何大括号。到目前为止,我有:
use strict;
use warnings;
open(INFILE,"<rscore") || die "Couldn't open rscore for reading!\n";
open(OUTFILE,">rscore.new") || die "Couldn't open rscore.new for writing!\n";
while(<INFILE>){
$_ =~ s/{/(/gi; #g for every occurrence, i for case-insensitive
print OUTFILE $_;
}
close INFILE;
close OUTFILE;
rename("rscore.new","rscore") || die "Couldn't rename the new file!\n";
并收到以下错误:
syntax error near line 10 near insensitive print.
这可能是一件愚蠢的事情。此外,如果有更有效的方法来做到这一点(我确信有),我愿意接受建议。