Subject: | "Nan" is a number! |
Date: | Wed, 29 Nov 2006 05:00:51 +0700 |
To: | bug-Scalar-List-Utils [...] rt.cpan.org |
From: | "Tim Bolshaw" <timothybolshaw [...] gmail.com> |
use Scalar::Util qw\looks_like_number\;
my $string = 'Nan';
if ( looks_like_number $string ) {
print "$string is a number\n";
}
else {
print "$string is a string\n";
}
It is obvious, of course, what is happening. It tickles my funny bone that
'Not-A-Number' looks like a number. Murphy's law applied: I was processing
a word array ... one of the words was "Nan"!
--
Tim Bolshaw
timothybolshaw@gmail.com
Mobile: +66-(0)87 072 5009