Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by cog (Parson)
on Dec 14, 2005 at 23:33 UTC ( [id://516800] : note . print w/replies, xml ) Need Help??


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

Or perhaps:

use List::MoreUtils; if (any { $variable == $_ } (1, 2, 3)) { ... }

With the disadvantage of using an extra module, but with the advantage of not testing every single value after the first successful one (if the list is big, it's probably a better alternative).