in reply to Re: Question re numbers and strings
in thread Question re numbers and strings

Hi,

Thanks for the reply guys - thats sheds some light on the matter :)

I think what I will do, is just use a regex for now then:

$var =~ /^[1-9]\d*$/

(the first bit is just to make sure its over 0 :))

Thanks again

Andy

Replies are listed 'Best First'.
Re^3: Question re numbers and strings
by ww (Archbishop) on Jan 13, 2011 at 13:14 UTC
    Just a tangential word of caution, Andy; quoting (determining interpolation) matters:
    C:>perl -e "my $var = '0x8';if ($var =~ /^[1-9]\d*$/) {print 'num' } e +lse {print 'not a num';}" not a num

    But

    C:>perl -e "my $var = 0x8;if ($var =~ /^[1-9]\d*$/) {print 'num' } els +e {print 'not a num';}" num