Title: Re: Test if string is a number?
|
How about regexp?
/^\-?(\d+\.?\d*|\.\d+)$/
----- Original Message -----
Sent: Thursday, June 30, 2005 4:48
PM
Subject: RE: Test if string is a
number?
Chris Wagner wrote, on Thu 6/30/2005 08:48
: Wow there's been a lot of heavy duty code proposed to do
something so : simple. The answer is in how Perl converts between the
two. : : print "is a number" if $var eq $var + 0; : print "not a
number" if $var ne $var + 0;
Except if $var is, say, '0.00'. Then $var + 0 is '0', and
won't eq $var.
Joe
==============================================================
Joseph P. Discenza, Sr.
Programmer/Analyst
mailto:[EMAIL PROTECTED]
Carleton Inc. http://www.carletoninc.com
574.243.6040 ext. 300 fax:
574.243.6060 Providing Financial Solutions and Compliance for
over 30 Years
_______________________________________________ Perl-Win32-Users
mailing list [email protected] To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs
|
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs