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

Re: Using IF and OR, I'm sure there is a better way

by eff_i_g (Curate)
on Dec 15, 2005 at 00:22 UTC ( [id://516816] : note . print w/replies, xml ) Need Help??


in reply to Using IF and OR, I'm sure there is a better way

I use something like this:
sub in_list { my $needle = shift || q{}; # or croak, your choice. croak 'expecting haystack' if not @_; return grep m/^$needle$/, @_; } if (in_list($var, qw(A B C))) { ... }

Replies are listed 'Best First'.
Re^2: Using IF and OR, I'm sure there is a better way
by eff_i_g (Curate) on Dec 15, 2005 at 00:27 UTC
    or return grep $_ eq $needle, @_; rather.