
第二步:把20个文件放在一个目录下,使用opendir 函数读取目录进行 *** 作,例如:
#!/usr/bin/perl
use warnings
use strict
my %hash
open IN, $file1 or die $!
while<IN>
{
$hash{$_}=1
}
my ($dirname, $filename)
$dirname = "E:/xiao/"
open OUT, ">c.txt" or die $i
opendir (DIR, $dirname ) || die "Error in opening dir $dirname\n"
while( ($filename = readdir(DIR))){
open (FILE, "E:/xiao/".$filename)|| die "can not open the file $filename\n"
while (<FILE>){
chomp
if(exists $hash{$_})
{ print OUT "$_\n" }
}
}
closedir(DIR)
my ( @m, $i ) = qw( <<>)my ( $x, $y, $z ) = map { open my ($f), $m[ $i++ ], $_$f } 'file1', 'file2', 'file3'
select $z
(split)[2] >( split /\s+/, <$y>)[2] ? print : undef while <$x>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)