in reply to Re: Answer: How to identify a number datatype in a string?
in thread How to identify a number datatype in a string?

Add the following after if(@){}, and you will see...

else { print "number: ", $test , "\n"; }

...Apparently, $test is assigned zero (perl 5.8.0) when $number is not a number. Ergo, no errors in eval, no print.

Replies are listed 'Best First'.
Re: Re: Re: Answer: How to identify a number datatype in a string?
by hossman (Prior) on May 30, 2003 at 22:19 UTC

    Acctually, $test is assigned $number regardless of what $number is ... if you do any mathematicly operations on a scalar which is "not a number" then that scalar is evaluated as "0" (and a warning is generated).

    Which was basicly my point ... the whole premese of this test is flawed. (uless you set up a signal handler for warnings, which causes a "die" to be thrown)

      Ah, ok then. Goal of your earlier post was not quite clear to me originally.