in reply to Test for numeric

You might want to check out merlyn's is_numeric function
sub is_numeric { ($_[0] & ~ $_[0]) eq "0"; }
Which tests whether a scalar is a numeric value or a string value e.g 42 vs "42".
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Test for numeric
by John M. Dlugosz (Monsignor) on Jun 21, 2003 at 20:26 UTC
    More like "this is not a digit at all" vs 42. It evaluates to 0 with a warning, which is the intention--to make sure you check for the zeros before doing arithmetic. But what's an elegant way to see if it's one of the strings without generating the warning? I was thinking of no warning whatever-it-is;, but thought that something direct was available with 5.8.