http://www.perlmonks.org?node_id=1007330


in reply to Reg Ex exercise

From Scalar::Util::looks_like_number
perldoc -m Scalar::Util::PP sub looks_like_number { local $_ = shift; # checks from perlfaq4 return 0 if !defined($_); if (ref($_)) { require overload; return overload::Overloaded($_) ? defined(0 + $_) : 0; } return 1 if (/^[+-]?[0-9]+$/); # is a +/- integer return 1 if (/^([+-]?)(?=[0-9]|\.[0-9])[0-9]*(\.[0-9]*)?([Ee]([+-]?[ +0-9]+))?$/); # a C float return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006 +001 and /^Inf$/i); 0; }