You could get it from an object that overloads numification (0+) or int

Yes, that would do it.

I did find a case where Scalar::Util::looks_like_number and the OP's isNumber return a different value for the same argument, but it had nothing to do with emission of warnings.

For the arguments Math::MPFR->new(), Math::MPFR->new('nan') and Math::MPFR->new('inf'), Scalar::Util::looks_like_number will return FALSE, while isNumber will return TRUE.

But this is probably the fault of Math::MPFR, which stringifies all values the same way as the mpfr library.
And those 3 expressions therefore get stringified as "@NaN@", "@NaN@" and "@Inf@" (respectively).

Math::MPFR probably should fix this by doing a s/@//g on the string prior to returning it. (And I'll attend to that.)

I'll also mention that there's a perl API subroutine also named looks_like_number, but it doesn't look for any magic and therefore returns FALSE for most objects.
Actually, I don't know of any cases where it will return TRUE for an object ... but I'm wary of asserting that such a case doesn't exist, or couldn't be constructed ...

Cheers,
Rob

In reply to Re^6: How to capture the "isn't numeric" warning? by syphilis
in thread How to capture the "isn't numeric" warning? by harangzsolt33

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.