Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://723041]
[Discipulus]: LA you know who is paco?
[Lady_Aleena]: Disc, nope.
[Discipulus]: ahi ahi ahi!!
[Lady_Aleena]: paco is a little over 2 years before my time.
[Discipulus]: you can try tachyon's iterative approach Re: Win32 Recursive Directory Listing
[Lady_Aleena]: I'm on Linux/
[beech]: isn't 2 year about standard recovery time for that kind of surgery?
[Discipulus]: if you hate FIle::Find
[Lady_Aleena]: I don't hate it, it just drives me crazy.
[Discipulus]: LA the solution is portable to whatever

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2017-04-23 20:39 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (432 votes). Check out past polls.