Close. I think ($_ eq int($_) && $_ > 0) will work as a condition though.
use strict; use warnings; my @tests = qw/12 1a 4 -3 0 0.1 .1/; for (@tests) { print "$_ => "; no warnings qw/numeric/; if ($_ eq int($_) && $_ > 0) { print 'ok'; } else { print 'bad'; } print "\n"; } __END__ C:\Perl\test>perl int_test.pl 12 => ok 1a => bad 4 => ok -3 => bad 0 => bad 0.1 => bad .1 => bad
In reply to Re^2: Check for Positive Integer entry only
by eric256
in thread Check for Positive Integer entry only
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |