E
EmmettPower
Hi,
I have a problem with what should be a simple issue. I am testing a
number of files in a directory for a pattern using a regular
expression. The successful matches are printed to the screen a file
(Output.txt). I've set out the code below. The pattern matches across
lines, hence the use of File::Slurp.
I'm using Perl on a Windows platform. The script works fine when I test
it on one computer but when I migrate it across to the computer holding
the files is fails to print the results to the Output file. It prints
to screen fine. Both computers are using the same version of Windows
and Perl.
It should be simple but I can't figure out what's wrong.
Any suggestions would be appreciated.
Regards
Emmett Power
<--------------------------CODE-------------------------------->
use File::Slurp;
my $file;
my $name;
my $FILELIST = "FileList.txt";
open(LIST, "$FILELIST");
open (OUT,'>Output.txt');
while(<LIST>)
{
chomp;
$name = $_;
$file = read_file($name);
while ($file =~ /test/gi){
print "$&,$_\n";
print OUT "$&,$_\n";
}
}
close(OUT);
close(LIST);
I have a problem with what should be a simple issue. I am testing a
number of files in a directory for a pattern using a regular
expression. The successful matches are printed to the screen a file
(Output.txt). I've set out the code below. The pattern matches across
lines, hence the use of File::Slurp.
I'm using Perl on a Windows platform. The script works fine when I test
it on one computer but when I migrate it across to the computer holding
the files is fails to print the results to the Output file. It prints
to screen fine. Both computers are using the same version of Windows
and Perl.
It should be simple but I can't figure out what's wrong.
Any suggestions would be appreciated.
Regards
Emmett Power
<--------------------------CODE-------------------------------->
use File::Slurp;
my $file;
my $name;
my $FILELIST = "FileList.txt";
open(LIST, "$FILELIST");
open (OUT,'>Output.txt');
while(<LIST>)
{
chomp;
$name = $_;
$file = read_file($name);
while ($file =~ /test/gi){
print "$&,$_\n";
print OUT "$&,$_\n";
}
}
close(OUT);
close(LIST);