Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: check if its a number

by nobull (Friar)
on Apr 12, 2008 at 14:23 UTC ( #679992=note: print w/replies, xml ) Need Help??

in reply to Re: check if its a number
in thread check if its a number

Yes you can write a function that tells you if a given string triggers the warning.

sub perl_thinks_it_is_number { eval { use warnings FATAL => 'numeric'; no warnings 'void'; 0+shift; 1; } } print "'foo' isn't a number\n" unless perl_thinks_it_is_number 'foo'; print "'17' is a number\n" if perl_thinks_it_is_number '17';
Note that this will consider '00' and some other oddities to be a number. You are probably better sticking with other answers elsewhere in this thread.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2023-06-06 10:33 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.