没有提取数据输出到data2.txt?代码出了什么问题?如何使用Perl来提取和保存文本?
MYFILE.TXT
ex1,fx2,xx1
mm1,nn2,gg3
EX1,hh2,ff7
这是data2.txt我想要的输出:
ex1,fx2,xx1
EX1,hh2,ff7
#! /DATA/PLUG/pvelasco/Softwares/PERLINUX/bin/perl -w
my $infile ='My1.txt';
my $outfile ='data2.txt';
open IN, '<', $infile or die "Cant open $infile:$!";
open OUT, '>', $outfile or die "Cant open $outfile:$!";
while (<IN>) {
if (m/EX$HF|ex$HF/) {
print OUT $_, "\n";
print $_;
}
}
close IN;
close OUT;
使用三个参数打开。 – 2008-10-17 19:20:02