bigbalbossa
Programmer
All,
I have been working on a small project that pulls keywords from a file, matches them to an array of control files, inserts matching records into a table and increments a count. The problem is how i'm matching keywords to the control files. I'm hoping one of you guys can help.
I'm constructing a regex like so:
Then, while looping through my control files, I get my matches:
This does a good job of getting matches, but the regex is a little too greedy. For example, if a control file contains Air: Last Activity and Air: Last Activity All on the same line...I match Air: Last Activity twice and not Air: Last Activity All.
Any thoughts on fixing this code or alternative solutions will help keep me sane
Thanks,
I have been working on a small project that pulls keywords from a file, matches them to an array of control files, inserts matching records into a table and increments a count. The problem is how i'm matching keywords to the control files. I'm hoping one of you guys can help.
I'm constructing a regex like so:
Code:
my $keyword_re = "(" . join( "|", map(quotemeta, sort(keys(%rap_kwds))) ) . ")";
Code:
while(<FILE2>) {
chomp;
my @matches = ( $_ =~ /Air: Last Activity/g );
foreach my $match ( @matches ) {
print "Match = $match\n";
}
}
Any thoughts on fixing this code or alternative solutions will help keep me sane
Thanks,