in reply to Fast/efficient way of check if a string in an strArr is contained in a line
Create a master regex. Let's say your options were
My criteria for good software:
You'd do something like:foo.*bar \w+\d+\s+\d+:\d$
It's not going to be as fast as a hash lookup, but it'll be faster than your for-loop in most cases. Plus, it'll be more self-documenting.my @skips = get_skips(); # However you get them my $skip_regex = join '|', map { "(?:${_})" } @skips; while ( <BIG_FILE> ) { next if /$skip_regex/; # Now you've checked everything. }
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
|
---|
In Section
Seekers of Perl Wisdom