Another approach if you want exact integer match. Not that much shorter but flexible for bigger range or more matches. See also Syntax::Keyword::Junction for more terse.
use List::Util 'any'; if (any {$x == $_} $y, $y +1, $y -1)
In reply to Re: IF condition with a range
by mr_ron
in thread IF condition with a range
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |