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.