Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to determine if something is numeric?

by Ovid (Cardinal)
on Jan 30, 2004 at 19:19 UTC ( [id://325344]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Scalar::Util 'looks_like_number';
    
    if (0 != substr($var,0,1) and looks_like_number($var)) {
        # it's a number
    }
    
  2. or download this
    use Scalar::Util 'looks_like_number';
    
    if ($var !~ /^-?0/ && looks_like_number($var)) {
        # it's a number
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-24 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found