http://www.perlmonks.org?node_id=250053


in reply to Making a match

How often does this need to be executed?
If you only need to perform the check once, use grep(), as the Anonymous Monk already suggested.
If, however, the check needs to be performed multiple times, say, in a loop, you'll be better off putting those numbers in a hash and then using exists(); e.g.,
my %numbers = (); @numbers{10..15,17,18,22..35} = (); if (exists $numbers{$x}){ # do stuff }
--perlplexer