If you're really checking for $var being eq to one of many elements, a hash would work.
my %look_for = map { $_ => 1 } qw( a b ... ); if ( $look_for{ $var } ) { }
That said, I don't see anything wrong with using a regular expression, if it does what you want. I'd only think grep is a problem if you have a huge number of items to check. Maybe you want List::Util::first here?
In reply to Re: long if statements... What's the best way?
by kyle
in thread long if statements... What's the best way?
by cosmicperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |