At 02:28 PM 6/30/05 -0500, Joe Discenza wrote:
>Regex is pretty fast. Eval is usually pretty slow.
Yeah ur right about the eval. I did a triple head to head with ur regex and
eval/no eval. The eq without the eval demolishes all.
Rate evalRE noeval
eval3397/s -- -87% -
Joe Discenza wrote:
> Chris Wagner wrote, on Thu 6/30/2005 14:41
>
> : At 12:16 PM 6/30/05 -0500, Joe Discenza wrote:
> : >I bet you're right that "eval($var) eq $var + 0" works; have you
> : >benchmarked it against all the other (regex, e.g.) methods presented?
> :
> : I haven't benchmarked it b
Title: RE: Test if string is a number?
Chris Wagner wrote, on Thu 6/30/2005 14:41
: At 12:16 PM 6/30/05 -0500, Joe Discenza wrote:: >I bet
you're right that "eval($var) eq $var + 0" works; have you: >benchmarked
it against all the other (regex, e.g.) methods p
At 12:16 PM 6/30/05 -0500, Joe Discenza wrote:
>I bet you're right that "eval($var) eq $var + 0" works; have you
benchmarked it against all the other (regex, e.g.) methods presented?
I haven't benchmarked it but I can garuntee that it's faster than a regex.
Anything's faster than that. ;) This sh
Title: RE: Test if string is a number?
Chris Wagner wrote, on Thu 6/30/2005 12:41
: At 09:48 AM 6/30/05 -0500, Joe Discenza wrote:: >Except
if $var is, say, '0.00'. Then $var + 0 is '0', and won't eq $var.:: 0.00
is not a valid internal representation of a nu
[EMAIL PROTECTED] wrote:
> 0.00 is not a valid internal representation of a number.
> That can only exist as a string.
I think "u" need to re-read the subject of this thread.
- Mark.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.Acti
At 09:48 AM 6/30/05 -0500, Joe Discenza wrote:
>Except if $var is, say, '0.00'. Then $var + 0 is '0', and won't eq $var.
0.00 is not a valid internal representation of a number. That can only
exist as a string. Same goes for "1e7". That is a print formated number,
not a valid internal number.
perl-win32-users@listserv.ActiveState.com
Subject: Re: Test if string is a number?
How about regexp?
/^\-?(\d+\.?\d*|\.\d+)$/
- Original Message -
From: Joe Discenza
To: Chris Wagner ; perl-win32-users
Sent: Thursday, June 30, 2005 4:48 PM
Subject: RE: Test if string is a number?
Chri
Title: Re: Test if string is a number?
How about regexp?
/^\-?(\d+\.?\d*|\.\d+)$/
- Original Message -
From:
Joe
Discenza
To: Chris Wagner ; perl-win32-users
Sent: Thursday, June 30, 2005 4:48
PM
Subject: RE: Test if string is a
number?
Chris
Chris Wagner wrote:
> 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;
>
> Say $var is "bob". In the first case we see if "
Title: 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 "no
> 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;
That fails on 1e7.
___
Perl-
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;
Say $var is "bob". In the first case we see if "bob" is string equal to bob
+ 0 or
Lyle Kopnicky wrote:
> Thanks folks. I think I'll go with looks_like_number from
> Scalar::Util. I like to use library routines where possible. I don't
> know how I overlooked that, since I poked through Scalar::Util earlier.
>
> It just seems bizarre to me that something like that isn't a b
Thanks folks. I think I'll go with looks_like_number from
Scalar::Util. I like to use library routines where possible. I don't
know how I overlooked that, since I poked through Scalar::Util earlier.
It just seems bizarre to me that something like that isn't a builtin. I
mean, you can't eve
15 matches
Mail list logo