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.,
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.,
--perlplexermy %numbers = (); @numbers{10..15,17,18,22..35} = (); if (exists $numbers{$x}){ # do stuff }
In Section
Seekers of Perl Wisdom