The mehod suggested by astaines works but the script he gives does not because perl only warns about adding to non-numeric variables, so this is not caught by the eval. It is therefore necessary to make warnings fatal within the eval block:
sub is_number { my $test = shift; eval { local $SIG{__WARN__} = sub {die $_[0]}; $test += 0; }; if ($@) {return 0;} else {return 1;} }
In reply to Re: How to identify a number datatype in a string?
by Bilbo
in thread How to identify a number datatype in a string?
by BBQ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |