in reply to IF condition with a range
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)
Ron
In Section
Seekers of Perl Wisdom