Well I assumed that as soon it will match the if condition it will break. and this is the reason that I should modify it.
I am not sure that I understand correctly what you are saying, and I am not sure that you understood what I was saying.

The FAQ's original code had continue statements so that every condition is checked, even if a previous condition succeeded. So that the FAQ code, presented with 1.0 would report a non digit and then also report a real number. Your code does not do that.

For your nested if ... elsif ... else statements to work properly, you need to reorder your conditions, for example: 1. check if it is a positive integer; 2. check for a negative integer; 3. check for a (positive or negative) float; 4. check for non-digits other than those we have accepted when checking for negative and floats.

my @numbers = (1, 1.0, 123.1, 0.1);
is certainly a good way of declaring an array of numbers, but I was only stressing that your use of qw/.../ was incorrect because of the commas.

In reply to Re^3: How do I determine with a regular expression whether a scalar is a number/whole/integer/float? by Laurent_R
in thread [SOLVED] How do I determine with a regular expression whether a scalar is a number/whole/integer/float? by thanos1983

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.