in reply to Re^3: Pattern match array
in thread Pattern match array

Thanks, this is of interest.

I think if I had known benchmarks would be run, I would have hashed instead of grepping.

my %sought = map {$_ => 1} @prims;

and later

if ($sought{$word})

And then there's List::MoreUtils::any, which would at least quit on the first match instead of checking the rest of the list.

Replies are listed 'Best First'.
Re^5: Pattern match array
by johngg (Canon) on May 09, 2008 at 13:56 UTC
    Using a hash instead of grepping does improve performance but the regex alternation still seems to retain the advantage.

    Rate Narveson Narveson2 JohnGG Narveson 1.39/s -- -30% -64% Narveson2 1.99/s 43% -- -48% JohnGG 3.81/s 174% 91% --

    Cheers,

    JohnGG