On Thu, 18 Oct 2001, Selector, Lev Y wrote: > > Any recommendations? something like this perhaps?
ns21# cat t.pl
#!/usr/bin/perl
sub isNumber {
!/\d/ ? 0 : $_ == 0 ? 1 : $_ * 1
}
for ( qw[ 0 abcdefg 1 -1.0 1.0e-10 10abc ] ) {
print "$_ -> ", isNumber($_), "\n";
}
ns21# perl t.pl
0 -> 1
abcdefg -> 0
1 -> 1
-1.0 -> -1
1.0e-10 -> 1e-10
10abc -> 10
