http://qs321.pair.com?node_id=325361


in reply to Re: Re: How to determine if something is numeric?
in thread How to determine if something is numeric?

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