Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Does it look like a number?

by xdg (Monsignor)
on Dec 15, 2004 at 17:16 UTC ( #415114=note: print w/ replies, xml ) Need Help??


in reply to Does it look like a number?

Lots more on this topic came up recently. See Detecting if a scalar has a number or string, which includes a lot of discussion about how to treat objects that overload like numbers. I personally like Re^3: Detecting if a scalar has a number or string by davido, which ducks a lot of the issues and tests to see if a given input would generate a warning if used in arithmetic -- which is what I usually find myself wanting to check when I'm being given user input (as opposed to whether something is represented internally as a number or string).

-xdg

Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.


Comment on Re: Does it look like a number?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-12-28 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls