in reply to How to identify a number datatype in a string?

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;} }