Last active
May 6, 2019 15:47
-
-
Save jdittmarCodeSnippets/5357923 to your computer and use it in GitHub Desktop.
Perl: isNumeric
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
# returns true if the value passed to it is numeric, false otherwise | |
sub isNumeric{ | |
no warnings; | |
use warnings FATAL => 'numeric'; | |
return 0 if(!defined $_[0] || $_[0] eq '' ); | |
return defined eval { $_[ 0] == 0 }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment