misterperl has asked for the wisdom of the Perl Monks concerning the following question:
Why does eval( "$x * 10" ) yield different numbers depending on if $x has leading zeros? This is more than perplexing, it's astounding! (Perl 5.8.8 on linux)# math my $x = "016"; my $y=$x * 10; print "y=$y\n"; # eval $y = eval( "$x * 10" ); print "evalled 016 * 10 , y = $y\n"; # eval without leading zero $x = "16"; $y = eval( "$x * 10" ); print "evalled 16 * 10 , y = $y\n"; me@ramster:~/perl$ ./x.pl y=160 evalled 016 * 10 , y = 140 evalled 16 * 10 , y = 160
|
|---|