Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by davido (Cardinal)
on Dec 15, 2005 at 03:00 UTC ( [id://516838] : note . print w/replies, xml ) Need Help??


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

List::MoreUtils' any() sub is one good way that someone mentioned. Another is a hashtable. But if the values are all contiguous, and you don't mind that floating point values could fall between '1' and '2', you could do it this way too:

if( $variable >= 1 and $variable <= 3 ) { #...

Dave