You could also use
if (abs($y-$x) <= 1) [download]
(Added to earlier post)
In reply to Re^3: IF condition with a range by ikegami in thread IF condition with a range by Anonymous Monk