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 (Archbishop) 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:  <%-{-{-{-<