perlquestion
mifflin
I need to determine if something is numeric.<br>
By numeric I mean...<br>
1. no alpha <br>
2. no leading zeros ( 0001 or -0001 needs to be considered not-numeric)<br>
<BR>
here is what I came up with<br>
<code>
use warnings;
use strict;
my $var = 'abc';
no warnings;
my $testvar = $var + 0;
use warnings;
if ($var eq $testvar) {
print "$var is numeric\n";
}
else {
print "oops, $var is NOT numeric\n";
}
</code>
Is this considered the right way to go about it?
Is there a better way?