Hello seki,
I read that you found your answer already to your question, but I think it is interesting to read also perlnumber, integer or even casting the numbers with int.
Related to your question, just a simple example:
#!usr/bin/perl use say; use strict; use warnings; use Math::Roman qw(roman); use Scalar::Util qw(looks_like_number); my @array = ("8", "", 8, "132.8", 132.8, "III", roman('III')); foreach my $array_element (@array) { if (looks_like_number($array_element)) { say "Element: ".$array_element." is a number"; } else { say "Element ".$array_element." isn't a number"; } } __END__ $ perl test.pl Element: 8 is a number Element isn't a number Element: 8 is a number Element: 132.8 is a number Element: 132.8 is a number Element III isn't a number Element: III is a number
I used Math::Roman and Scalar::Util. Also this is a frequently asked question perlfaq4/How do I determine whether a scalar is a number/whole/integer/float?.
Similarly asked question A function to determine if a string is numeric.
Hope this helps, BR.
In reply to Re: Argument "" isn't numeric in division (/)
by thanos1983
in thread Argument "" isn't numeric in division (/)
by seki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |