Perl, integer and floats
How can I check if a number is integer (2 3 123 12122134) or float (1.2 112.56 0.3333) ?
I tried to split it at the decimal point, but the split() function doesn't work with digits (i think): $test = $i/$n; @fields = split (/./,$test); And here @fields is always emty. |
You can split on the decimal point, however, the dot is a meta-character (it actually stands for any character at all), so it must be escaped with a backslash. Try:
Code:
@fields = split (/\./,$test); Code:
if ($test ~= m/\./) { |
Thanks, I noticed that ;)
|
All times are GMT -5. The time now is 07:10 PM. |