integer persoon code example

Example 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";
}

Example 2: scanf integer

int integer;
scanf("%d", &integer);

Tags:

Cpp Example