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.
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.my @numbers = (1, 1.0, 123.1, 0.1);
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |