Answers for "perl validate integer"

1

perl validate integer

# 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";
}
Posted by: Guest on May-11-2020

Browse Popular Code Answers by Language