in reply to Regex perl grep usage string match comparison
In addition to the previous suggestions, you can eliminate the loop over @configLineItems by compiling a regular expression with qr like this:
my $regex = join '|', map {quotemeta} @configLineItems; $regex = qr/$regex/;
(If @configLineItems contains regular expressions, then drop the "map {quotemeta}".)
This is something you can do when you read the configuration file before the loop over the input file, storing $regex for use during the main loop over the input. You can then use it like so: if ($Line[6] =~ $storedRegex)
As was said earlier, as much as we like to help, this isn't a code writing service - please try to implement these suggestions and if you need help doing so please don't hesitate to ask.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex perl grep usage string match comparison
by justinkala (Initiate) on Oct 12, 2014 at 02:51 UTC | |
by Athanasius (Archbishop) on Oct 12, 2014 at 04:15 UTC |