When is the spaceship operator used outside a sort?

operators, perl, sorting, spaceship-operator

Solution

I'm writing a control system for robot Joe that wants to go to robot Mary and recharge her. They move along the integer points on the line. Joe starts at $j and can walk 1 meter in any direction per time unit. Mary stands still at $m and can't move -- she needs a good recharge! The controlling program would look like that:

while ($m != $j) {
    $j += ($m <=> $j);
}

Problem

I've only seen the Perl spaceship operator (<=>) used in numeric sort routines. But it seems useful in other situations. I just can't think of a practical use. What would be an example of when it could be used outside of a Perl sort? This is a best practice question.

Original source