Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: is_numeric

by jdporter (Paladin)
on Apr 11, 2007 at 21:00 UTC ( [id://609484]=note: print w/replies, xml ) Need Help??


in reply to is_numeric

Very clever.

Perhaps too clever?

print is_numeric([]) ? "yes\n" : "no\n";
yes
A word spoken in Mind will reach its own level, in the objective world, by its own weight

Replies are listed 'Best First'.
Re^2: is_numeric
by GrandFather (Saint) on Apr 11, 2007 at 21:25 UTC
    return eval { ! ref $x and $x == $x };

    is a light weight way to fix that case.


    DWIM is Perl's answer to Gödel
      But if you do that, objects that overload numerification to return a number won't be considered numbers...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://609484]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2025-06-13 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.