In Perl the comparison operators for numbers are <
, ==
, >
, <=
, >
. If you use the string operators (le
, ge
, etc) you are comparing the numbers as strings. So, for example, 10
is greater than 1
but less than 4
.
Also note that you’re doing redundant testing. Consider
if($_[0] < 1) { you didn't cover this case }
elsif($_[0] <= 4) { $x_id = "x.1"; }
elsif($_[0] <= 8) { $x_id = "x.2"; }
elsif($_[0] <= 12) { $x_id = "x.3"; }
etc...