You can use looks_like_number() in conjunction with int() to tell what type of number you have.
#!/usr/bin/perl use strict; use warnings; use Scalar::Util qw(looks_like_number); my $x = $ARGV[0]; if (looks_like_number($x)) { if (int($x) == $x) { print("$x is an integer\n"); } else { print("$x is numeric\n"); } } else { print("Your input was not numeric\n"); }
In reply to Re: How to identify a number datatype in a string?
by jdhedden
in thread How to identify a number datatype in a string?
by BBQ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |