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

In reply to Re: Dangerous Names by ccn
in thread Dangerous Names by samtregar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.