learingperl01
MIS
Hello,
Wondering if someone could please help me out. I am pretty new with Perl and still learning. I am having problem with the following script shown below. The problem is that I don't want it to print out the same filename if more than one match is found...Meaning if the regex matches once then stop and move onto the next file. What it is doing right now for example is that if the log contains "abc.exe" "def.exe" "test.exe". Then I get a print out showing 080501.bk.dc01 three times. What do I need to add/change so that the script stops looking in the file after one match?
thanks for the help in advance.
Wondering if someone could please help me out. I am pretty new with Perl and still learning. I am having problem with the following script shown below. The problem is that I don't want it to print out the same filename if more than one match is found...Meaning if the regex matches once then stop and move onto the next file. What it is doing right now for example is that if the log contains "abc.exe" "def.exe" "test.exe". Then I get a print out showing 080501.bk.dc01 three times. What do I need to add/change so that the script stops looking in the file after one match?
thanks for the help in advance.
Code:
#!/usr/bin/perl
use File::Find;
use MIME::Parser;
find(\&edits, $DIRECTORY);
sub edits() {
if ( -f and /^log\..*dc01$/ ) {
my %seen;
open LOG, "< $_" or die "Could not open $File::Find::name\n$!\n";
foreach my $each_line (<LOG>) {
if ( $each_line =~ /(filename=)\".+\.exe\"/xi ) {
print "$File::Find::name\n";
}
}
}
}