in reply to Efficiency: Foreach loop and multiple regexs

A better option might be to join the regex array together as a single regex made up of alternations
my $regex = do { local $" = '|'; qr/(?:@regexes)/; }; my @matches = grep /$regex/, @array;

HTH

_________
broquaint

update: changed code re neilwatson's clarification

Replies are listed 'Best First'.
Re: Re: Efficiency: Foreach loop and multiple regexs
by RMGir (Prior) on Sep 13, 2002 at 14:37 UTC
    Or use Regex::PreSuf, which takes such an array and builds a more optimal regex from it.
    --
    Mike