Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Equivalent to Integer?

by screamingeagle (Curate)
on Feb 11, 2002 at 07:18 UTC ( #144592=note: print w/replies, xml ) Need Help??

in reply to Equivalent to Integer?

quoting from PerlFaq4, here are various ways to check if a scalar variable is a number/whole/integer/float :
if (/\D/) { print "has nondigits\n" } if (/^\d+$/) { print "is a whole number\n" } if (/^-?\d+$/) { print "is an integer\n" } if (/^[+-]?\d+$/) { print "is a +/- integer\n" } if (/^-?\d+\.?\d*$/) { print "is a real number\n" } if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number" } if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/) { print "a C float" }
(Take your pick)... and if u want to use a negated regular expression, use the
syntax instead of the

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://144592]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2017-02-20 07:24 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (294 votes). Check out past polls.