Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to identify a number datatype in a string?

by Bilbo (Pilgrim)
on May 09, 2003 at 13:08 UTC ( [id://256848]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://256848]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-19 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found