in reply to How to identify a number datatype in a string?

Scalar::Util has a function looks_like_number() for just this purpose. It is included in Perl 5.8, or you can get it from CPAN.

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