Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to efficiently search for list of strings in multiple files?

by clueless newbie (Deacon)
on Aug 17, 2018 at 22:28 UTC ( #1220542=note: print w/replies, xml ) Need Help??


in reply to How to efficiently search for list of strings in multiple files?

Change the number of regexes that you need to one via Regexp::Assemble reducing the inner loop from many to 1?

use Regexp::Assemble; my $ra = Regexp::Assemble->new; $ra->add( q{Sarnia Employees' Bargaining Association} ); $ra->add( q{Sarnia Municipal Administrative Employees' Assn} ); $ra->add( q{Sarnia Police Association} ); $ra->add( q{Sarnia Professional Fire Fighters} ); print $ra->re;

which yields a single regex:

(?^:Sarnia (?:(?:Municipal Administrative Employees' Ass|Employees' Bargaining Associatio)n|P(?:rofessional Fire Fighters|olice Association)))

which you could always feed to ack.

Changed to q{} per AnomalousMonk's post. Thanks AnomalousMonk!

Replies are listed 'Best First'.
Re^2: How to efficiently search for list of strings in multiple files?
by AnomalousMonk (Bishop) on Aug 18, 2018 at 16:39 UTC
    $ra->add( 'Sarnia Employees' Bargaining Association' );

    It's hard to see how single-quoted strings containing unescaped single-quotes could compile. Could you please fix your example code?


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1220542]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2019-11-22 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (111 votes). Check out past polls.

    Notices?