在打开文件句柄的过程中出现这个问题。希望高手能解答
在打开文件句柄的过程中出现这个问题。希望高手能解答
我是perl的新手。使用的是active perl。
文件夹下面有150个文件大约30多个是results开头的。
程序如下:
#! c:\perl\bin\
use strict;
use warnings;
#use diagnostics;
use File::Copy;
use File::Compare;
chdir"E:\\" or die "cannot chdir E:\\Logs:$!";
chomp(my $Products=<STDIN>);
chomp(my $NewbuildNum=<STDIN>);
chomp(my $OldbuildNum=<STDIN>);
chomp(my $Platform=<STDIN>);
chomp(my $NewbuildPath = "E:\\Logs\\Build_logs\\$Products\\$NewbuildNum\\$Platform");
chomp(my $OldbuildPath = "E:\\Logs\\Build_logs\\$Products\\$OldbuildNum\\$Platform");
chomp(my $LogdiffPath = "E:\\Logs\\Build_logs\\Build_Diff\\$Products\\$NewbuildNum-$OldbuildNum\\$Platform");
chdir($LogdiffPath) or die "cannot chdir LogdiffPath:$!";
open Errorlogs, ">Errorlogs\.txt" or die "cannot open Errorlogs:$!";
print Errorlogs "Errors: \n";
open(Warninglogs, ">Warninglogs\.txt") or die "cannot open Warninglogs:$!";
print Warninglogs "Warnings: \n";
chdir($NewbuildPath) or die "can not chdir NewbuildPath:$!";
opendir(NewbuildPath, "$NewbuildPath") or die "can not opendir NewbuildPath:$!";
my @NewbuildFile = readdir NewbuildPath;
@NewbuildFile = sort @NewbuildFile;
for my $NewbuildFile(@NewbuildFile){
if($NewbuildFile=~/^(results)/){
print "$NewbuildFile \n";
open(NewbuildFileContent, "<$NewbuildFile") or die "can not open $NewbuildFile:$!";
while(my $NewbuildFileString=<NewbuildFileContent>){
if($NewbuildFileString =~/[1-9]+ errors/){
copy("$NewbuildFile",$LogdiffPath);
#rename "$NewbuildFile","Error\-$NewbuildNum\-$NewbuildFile";
#chdir($OldbuildPath) or die "cannot chdir OldbuildPath:$!";
#copy("$OldbuildPath\\$NewbuildFile",$LogdiffPath);
#rename "$NewbuildFile","Error-$OldbuildNum-$NewbuildFile";
chdir($LogdiffPath) or die "cannot chdir LogdiffPath:$!";
open Errorlogs, ">>Errorlogs\.txt" or die "cannot open Errorlogs:$!";
print Errorlogs "$NewbuildFile \n";
close Errorlogs;
}
chdir($NewbuildPath) or die "can not chdir NewbuildPath:$!";
if($NewbuildFileString =~ /[1-9]+ warnings/){
copy("$NewbuildFile",$LogdiffPath);
#rename "$NewbuildFile","Warning-$NewbuildNum-$NewbuildFile";
#chdir($OldbuildPath) or die "cannot chdir OldbuildPath:$!";
#copy("$OldbuildPath\\$NewbuildFile",$LogdiffPath);
#rename "$NewbuildFile","Warning-$OldbuildNum-$NewbuildFile";
chdir($LogdiffPath) or die "cannot chdir LogdiffPath:$!";
open(Warninglogs, ">>Warninglogs\.txt") or die "cannot open Warninglogs:$!";
print Warninglogs "$NewbuildFile \n";
close Warninglogs;
}
}
close NewbuildFileContent;
}
}
程序运行结果:
D:\>perl try.pl
Cypress
50727.810.00
50727.809.00
x86ret
results_EADDDROPS01_01_01.log
results_EADDDROPS01_02_01.log
results_EADDDROPS01_04_01.log
results_EADTBLD27_01_01.log
results_EADTBLD27_02_01.log
results_EADTBLD27_02_02.log
results_EADTBLD27_02_03.log
results_EADTBLD27_02_04.log
results_EADTBLD27_02_05.log
results_EADTBLD27_02_06.log
results_EADTBLD27_02_07.log
results_EADTBLD27_02_08.log
results_EADTBLD27_02_09.log
results_EADTBLD27_02_10.log
results_EADTBLD27_02_13.log
can not open results_EADTBLD27_02_13.log:No such file or directory at try.pl line 34.
line34就是open(NewbuildFileContent, "<$NewbuildFile") or die "can not open $NewbuildFile:$!";
我想请问是不是打开文件句柄的数量有限制?