Perl wants to see numbers around
<=> (spaceship) operator and converts strings to numbers.
"Nan" and "NaN" are both converted to zero.
Update: Strings which start with "nan" (/^nan/i) are converted to nan, others which start with "inf" (/^inf/i) converted to inf. Others are converted to zero unless begin with digits.
see perldoc peldata (Scalar values)
#!/usr/bin/perl -l --
use strict;
use warnings;
my @s =qw(nan naNo inf InfInity infimum foo bar 123dd);
print "$_ => ", $_+0 for @s;
__END__
Argument "naNo" isn't numeric in addition (+) at a.pl line 7.
Argument "infimum" isn't numeric in addition (+) at a.pl line 7.
Argument "foo" isn't numeric in addition (+) at a.pl line 7.
Argument "bar" isn't numeric in addition (+) at a.pl line 7.
Argument "123dd" isn't numeric in addition (+) at a.pl line 7.
nan => nan
naNo => nan
inf => inf
InfInity => inf
infimum => inf
foo => 0
bar => 0
123dd => 123