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

Re: How to determine a variable value is a number

by elusion (Curate)
on Aug 03, 2002 at 01:03 UTC ( #187260=note: print w/replies, xml ) Need Help??


in reply to How to determine a variable value is a number

In a regex, \d stands for a digit, so if you use
if ($item =~ /^\d+$/) { # do something }
It will do something for every item that contains only digits. The ^ marks the start and $ marks the end of the string, telling the regex that you want it to match only if every character can be matched. Hope this helps.

elusion : http://matt.diephouse.com

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2019-07-20 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?