in reply to Re: numeric comparison
in thread numeric comparison
Perl 5.8.1's stock Scalar::Util has looks_like_number(). Here's a little workout to show what it can and can't do,
use Scalar::Util 'looks_like_number'; my @candidates = qw/ 1 1.1 1,1 0E0 0e0 0377 100_000 0xdeadbeef/; print $_, looks_like_number($_)? ' is' : ' is not', ' a number.', $/ for @candidates; __END__ 1 is a number. 1.1 is a number. 1,1 is not a number. 0E0 is a number. 0e0 is a number. 0377 is a number. 100_000 is not a number. 0xdeadbeef not is a number.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: numeric comparison
by BrowserUk (Patriarch) on Jul 15, 2003 at 15:06 UTC |