use Types::Common::Numeric 1.003_002 qw(IntRange); my $range = IntRange[ $y-1 => $y+1 ]; if ($range->check($x)) { ...; }