Last active
January 8, 2018 12:03
-
-
Save eienf/afb86a65c9830c86c8a11fb6ea04a807 to your computer and use it in GitHub Desktop.
Check whether the variable is integer. Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
sub is_num { | |
my ($val) = @_; | |
if ( $val =~ /^-?\d+$/ ) { | |
return 1; | |
} | |
return 0; | |
} | |
sub test_is_num { | |
my ($val) = @_; | |
my $res = is_num($val); | |
print("$val: $res\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment