Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How to determine if something is numeric?

by Ovid (Cardinal)
on Jan 30, 2004 at 19:19 UTC ( #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
Node Status?
node history
Node Type: note [id://325344]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2021-04-16 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?