Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to determine a variable value is a number

by elusion (Curate)
on Aug 03, 2002 at 01:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://187260]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-25 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found