use Scalar::Util; . . if(Scalar::Util::looks_like_number($x) && $x > 0 && $x == int($x)) { print "It's a positive integer"; }