Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Checking whether a $var is a number

by George_Sherston (Vicar)
on Sep 05, 2001 at 01:37 UTC ( [id://110169]=note: print w/replies, xml ) Need Help??


in reply to Re: Checking whether a $var is a number
in thread Checking whether a $var is a number

Yes. That (together with a || $x==1 && substr($x,1,1) ne '1') does exactly what I find myself wanting nine times out of ten. That is, what isNaN does in js. I'd find it useful to have a built in function, and maybe we're going to get one.

§ George Sherston

Replies are listed 'Best First'.
Re: Re: Re: Checking whether a $var is a number
by John M. Dlugosz (Monsignor) on Sep 05, 2001 at 02:39 UTC
    Hmm, when does a scalar convert to 1 when it's not a number?

    Note that I didn't mention that you should already know that the value is "a string" rather than a reference or funky blessed overloaded object, but carefully worded it because I had that in mind.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found