in reply to Dangerous Names
Update: Strings which start with "nan" (/^nan/i) are converted to nan, others which start with "inf" (/^inf/i) converted to inf. Others are converted to zero unless begin with digits.
see perldoc peldata (Scalar values)
#!/usr/bin/perl -l -- use strict; use warnings; my @s =qw(nan naNo inf InfInity infimum foo bar 123dd); print "$_ => ", $_+0 for @s; __END__ Argument "naNo" isn't numeric in addition (+) at a.pl line 7. Argument "infimum" isn't numeric in addition (+) at a.pl line 7. Argument "foo" isn't numeric in addition (+) at a.pl line 7. Argument "bar" isn't numeric in addition (+) at a.pl line 7. Argument "123dd" isn't numeric in addition (+) at a.pl line 7. nan => nan naNo => nan inf => inf InfInity => inf infimum => inf foo => 0 bar => 0 123dd => 123
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dangerous Names
by samtregar (Abbot) on Dec 17, 2008 at 21:58 UTC | |
by ikegami (Patriarch) on Dec 17, 2008 at 22:04 UTC | |
by samtregar (Abbot) on Dec 17, 2008 at 22:05 UTC | |
by ikegami (Patriarch) on Dec 17, 2008 at 22:09 UTC | |
by samtregar (Abbot) on Dec 17, 2008 at 22:13 UTC | |
|