in reply to Re: validate if output of command is numeric or not
in thread validate if output of command is numeric or not
Again.
sub _isNumeric($){ my $t = shift; defined($t) or confess; no warnings; my $a = $t; $a+=0; return $a eq $t; }
This should be built in! Doing $a+=0 issues a warning. Unless you a a very careless programmer your code must issue no warnings for valid input. So if you are testing if input is numeric (where it may or may not be, both cases valid) then you have to jump through hoops like this.
That code above may not work for all cases but it is enough for my purposes.
Yet another reason to hate Perl. Fix it Larry!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: validate if output of command is numeric or not
by Anonymous Monk on Feb 29, 2016 at 19:01 UTC |