in reply to Numification of strings
All your examples except the first involve mixed alphanumerics... which, when numified -- via automatic conversion -- are converted by discarding "(t)railing non-number stuff and leading whitespace" 1 (and use warnings will call that to your attention) while treating leading (after discarding whitespace) numerals as a number.
What's more, if $x = "LanX" (no numerals, as in your line 1, "DB<9>") numification will treat $x as 0, whether you add, subtract, multiply or perform any other arithmetic operation...
perl -e "$x="LanX"; print ($x * 3);" 0
I don't know enough about perlguts to be sure morgon's suppostion about atoi is correct, but it certainly sounds plausible. On the other hand, I can't see how a well-defined and well-documented behaviour is "hiding ugly bugs."
1 Learning Perl, 3rd Ed (paper), Schwartz & Phoenix, p26.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Numification of strings
by LanX (Saint) on Aug 02, 2010 at 12:14 UTC | |
by ww (Archbishop) on Aug 02, 2010 at 12:48 UTC |