in reply to How to determine if something is numeric?
If I've understood your specs correctly:
use Scalar::Util 'looks_like_number'; if (0 != substr($var,0,1) and looks_like_number($var)) { # it's a number }
Update: As sporty pointed out below, this breaks on negative numbers. I didn't see that dash in your post. Here's the fix:
use Scalar::Util 'looks_like_number'; if ($var !~ /^-?0/ && looks_like_number($var)) { # it's a number }
Cheers,
Ovid
New address of my CGI Course.
In Section
Seekers of Perl Wisdom