mifflin,
looks_like_number was introduced in version 1.10 of Scalar::Util. The sub looks like this:
sub looks_like_number {
local $_ = shift;
# checks from perlfaq4
return 1 unless defined;
return 1 if (/^[+-]?\d+$/); # is a +/- integer
return 1 if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); #
+a C float
return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006
+001 and /^Inf$/i);
0;
}
As I stated in my reply - I do not think this meets your requirements because it also handles decimals, scientific notation, NaN, and Inf.
Cheers - L~R | [reply] [d/l] |
It looks like Scalar::Util uses List::Util and that version in my system is 1.07_00
any ideas?
Upgrade :)
| MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] |