my $str = "42x"; print $str == int($str) ? "==" : "!="; # "==" print $str eq int($str) ? "eq" : "ne"; # "ne"