Weirdest perl bug ever...

Matts on 2003-07-08T15:28:56

OK, probably not "ever", but definitely odd. Try and replicate this:

Sort subroutine didn't return a numeric value at /path/to/Module.pm line 92
And line 92 is:
my @sorted = sort { $b->[2] <=> $a->[2] } @probs;
(i.e. it's part of what almost looks like a long-hand Schwartzian transform).

Nobody on #london.pm could replicate the error message, although admittedly we didn't try very long.

I got this error emailed to me automatically from our scanning system, which sends me an email when an exception occurs. I received 1 only, out of about a billion ore more emails processed.

My theory is this is just cosmic rays. But it's certainly most odd looking.


Answer

rafael on 2003-07-08T16:04:16

$ perl -e '@x=sort{$a->[2]<=>$b->[2]}[0,0,0e9999],[0,0,0]'

That's because <=> returns undef when it encounters NaN.