*mifflin has asked for the wisdom of the Perl Monks concerning the following question:*

I need to determine if something is numeric.

By numeric I mean...

1. no alpha

2. no leading zeros ( 0001 or -0001 needs to be considered not-numeric)

here is what I came up with

By numeric I mean...

1. no alpha

2. no leading zeros ( 0001 or -0001 needs to be considered not-numeric)

here is what I came up with

Is this considered the right way to go about it? Is there a better way?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"; }

Back to
Seekers of Perl Wisdom