D. Pinard
0
Q:

perl validate int

# For Perl (language) only

# Headers to use
use Scalar::Util 'looks_like_number';

# syntax 
looks_like_number(<your-possible-integer>)

# example (copy-paste, and then run the following to see what happens)
use Scalar::Util 'looks_like_number';
my $iNum = "123";
if ( looks_like_number($iNum) ) {
	print "$iNum is a valid integer!" . "\n";
}
else {
	print "$iNum is NOT a valid integer!" . "\n";
}
1

New to Communities?

Join the community