Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Does it look like a number?

by xdg (Monsignor)
on Dec 15, 2004 at 17:16 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (None)
    As of 2024-09-10 05:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.