in reply to Comparing against multiple values
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 ) { ... }
|
---|