in reply to Re: Re: Numerical value of strings
in thread Numerical value of strings
In all honesty, I would do steps 1 and 2 once and incorporate 3 as part of my regular script to ensure my data didn't get polluted with erroneous entries.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; }
Cheers - L~R
|
|---|