Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Comparing against multiple values

by dws (Chancellor)
on Mar 18, 2002 at 19:34 UTC ( #152571=note: print w/replies, xml ) Need Help??


in reply to Comparing against multiple values

While that's very easy, it's not as fast as using a comparison operator such as 'eq'

If you're truly concerned about speed, use a /o modifier to compile the regex once, rather than re-interpolating the variable each time the regex is fired.

You'll also need to fix the regex to avoid false positives. Here's how I do it:

my $re = "\A(?:" . join("|", $foo, $bar, $baz) . ")\Z"; ... if ( /$re/o ) { ... }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://152571]
help
Chatterbox?
and the universe expands...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-07-18 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (383 votes). Check out past polls.

    Notices?