in reply to Testing For Numberness Vs Stringness
foreach (3,'3',3.0,'3.0',3.1,'3.1') { print "$_ is ", is_numeric($_) ? '':'not ', "numeric\n"; } sub is_numeric { ($_[0] & ~ $_[0]) eq "0"; } $ ./is_numeric.pl 3 is numeric 3 is not numeric 3 is numeric 3.0 is not numeric 3.1 is numeric 3.1 is not numeric
-b
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing For Numberness Vs Stringness
by BrooklineTom (Novice) on Nov 27, 2004 at 17:41 UTC |