Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Fast/efficient way of check if a string in an strArr is contained in a line

by dragonchild (Archbishop)
on Nov 12, 2008 at 01:05 UTC ( #723041=note: print w/replies, xml ) Need Help??


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
foo.*bar \w+\d+\s+\d+:\d$
You'd do something like:
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. }
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 criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://723041]
help
Chatterbox?
[Discipulus]: here quite well thanks. still alive. Unfortunately I have the 64Kb limit
Discipulus now is read a book to my daugther time. Just after she and mother stop yelling in the bathroom
[Lady_Aleena]: See you later, Discipulus. Have fun reading to your daughter.
Discipulus still yelling..;=(

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-09-24 18:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (274 votes). Check out past polls.

    Notices?