use experimental 'smartmatch'; if (($y-$x) ~~ [-1, 0, +1]) { ... }