|
|
| No such thing as a small change | |
| 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?? |
|
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.
In Section
Snippets Section
|
|
||||||||||||||||||||