Hi,
I have a list of files which are mentioned in "filelist.t xt". I need to check for a particular word in all the files. If it is found we need to get the filename.
I have the code for the same below. The code looks big ..Any modified version with less lines will be usefull..
I have a list of files which are mentioned in "filelist.t xt". I need to check for a particular word in all the files. If it is found we need to get the filename.
I have the code for the same below. The code looks big ..Any modified version with less lines will be usefull..
Code:
open (FH, qq*<filelist.txt*) || die "Can't find the filelist.txt";
open (FH5, ">final.txt");
while(chomp($mfile=<FH>))
{
if (-e $mfile)
{
my $filename=1;
open (FH2,"$mfile");
while(<FH2>)
{
if($_=~/FAIL/)
{
$filename=0;
}
}
if($filename)
{
print FH5 "$mfile\n";
}
}
}
close(FH);
close(FH5);
close(FH2);
Comment