Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How to implement numeric checking in my program.

by ikegami (Patriarch)
on Nov 16, 2010 at 01:37 UTC ( [id://871615]=note: print w/replies, xml ) Need Help??


in reply to How to implement numeric checking in my program.

@_ can't be a numeric value. It's an array. I think you want to check that each element of @_ is a numeric value. So check each element of @_ in turn. If you find one that isn't numeric, return undef. Otherwise, proceed with your calculations.

PS - Sorting to find the highest value doesn't scale as well as simply checking each value in turn to see if it's higher than the highest one seen to date.

PPS - Your prof could have used Scalar::Util's looks_like_number rather than using fatal warnings and eval. His solution doesn't even work in all circumstances. (Specifically, objects that numify to undef.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-23 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found