问题说明:假设有文件夹data,里面含有很多.TXT域名的文件,而文件里有特定字符需要匹配,并输出该行。
#!/usr/bin/perl -w
use strict;
opendir IN,"data" || die "can't open : $!\n";
open OUT,">>outfile";
my @file=grep (/\.TXT/,readdir IN);
foreach my $list(@file){
open TWO,"data/$list" or die $!;
my @second=;
for $_(@second){
if ($_=~m/^[\S+]/sg){
print OUT"$_";
}
}
}
exit;
阅读(690) | 评论(0) | 转发(0) |