On Thu, Oct 18, 2001 at 04:49:56PM -0400, Selector, Lev Y wrote:
> I have a (simple) Perl question.
> Is there a standard function in perl which can tell me
> if a string represents a valid number?
> (including integer, with decimal point and scientific notaion with "e").
When in doubt, ask Perl.
sub is_num {
my($cand) = shift;
my $not_num;
local $^W = 1;
local $SIG{__WARN__} = sub {
$not_num = $_[0] =~ /^Argument ".*?" isn't numeric/;
};
() = $cand + 0;
return !$not_num;
}
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
Don't be a lover, girl, I'd like to shamelessly hump your inner child.