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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|