Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to determine if something is numeric?

by stefp (Vicar)
on Jan 31, 2004 at 18:49 UTC ( #325568=note: print w/ replies, xml ) Need Help??


in reply to How to determine if something is numeric?

If by numeric, you means a string that represents a natural integer in the decimal numeration system which first digit is not a zero, it happens to be a string $s that is left unchanged by the operation: $s+0

print +($_+0 eq $_ ? ' ' : 'not '). "numeric: $_\n" for qw( 1 01 + a01 -3 -01 .1 ) numeric: 1 not numeric: 01 not numeric: a01 numeric: -3 not numeric: -01 not numeric: .1
oops, I read you specif without reading the code. I came with the same solution as you.

-- stefp


Comment on Re: How to determine if something is numeric?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2015-08-01 02:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls