Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: I don't understand.

by Anonymous Monk
on Nov 05, 2008 at 16:07 UTC ( [id://721705]=note: print w/replies, xml ) Need Help??


in reply to Re: I don't understand.
in thread Detecting if a scalar has a number or string

Ok, here's a bit of enhancement:
foreach $abc ("asd","","0","123","-12","1.2","-1.2","12-","-a12","a1") {print "$abc:", is_a_num($abc) ? "Number" : "NaN", "\n";} sub is_a_num { return ($_[0] =~ /^(\+|-)?([0-9]|\.)+$/) || 0 ; }
Thierry

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-16 05:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found