in reply to Bulk Regex?

Regex::PreSuf would give you a more optimal "$bigpattern". Apart from that, nothing else springs to mind.

Could you find some simpler way to recognize "interesting" lines? Maybe they have some other characteristic, apart from matching one of your regexes (regexs, regexen, whichever you prefer:)).
--
Mike

Replies are listed 'Best First'.
Re: Re: Bulk Regex?
by meetraz (Hermit) on Aug 29, 2002 at 16:08 UTC
    Thanks! I tried this, and it appears to speed execution by 5-7% with the current environment. Basically, this application accepts a list of department code prefixes and searches through a list of employees to extract those that match. I'm actually split()ing each line of the file and matching only one field, using the other fields in business logic if any of the department code prefixes match.
      Aha! Then don't use a regex.
      # substitute in your dept codes, and a better hash name :) my %deptCodesICareAbout=( RSRCH => 1, SALES => 1 ); # substitute in the right FILE, field list, and delimiter... while(<FILE>) { my ($code, #whateverelse )=split/,/; if($deptCodesICareAbout{$code}) { # business logic } }
      That will be MUCH faster.
      --
      Mike
        I wish it were that simple! What I have are dept code *prefixes* which are not necessarily all the same length. For example, if our department codes were like:

        ABCD123456 DEFG123456 DEFG998800 DEEE11223344

        The code prefixes I have are like:

        ABCD12 DEF DEEE11223

        In other words, they can be any length. I tried using something like this:

        foreach my $pattern (@patterns) { if (substr($fields[7],0,length($pattern)) eq $pattern) { ### Code here last; } }
        but that was slightly slower than the regex methods.