dilpane has asked for the wisdom of the Perl Monks concerning the following question:
I got the output:use strict; use warnings; my ($a, $b) = ("1_334", 1334); $a += 1; $b += 1; print "$a $b\n"; print "Unequal\n" if ($a != $b); print "$a $b\n";
My question is if $a has already become 2, why does the comparison see "1_334". Also I would have thought that the numeric operator would have considered it as a string (in which case $a should have been 0+1) and evaluated to 1 or as a number 1334 and evaluated to 1335; either way being coverted to a number...2 1335 Argument "1_334" isn't numeric in addition (+) at noname.pl line 6. Unequal 2 1335
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: _ in a number within quotes
by ELISHEVA (Prior) on Apr 19, 2009 at 15:31 UTC | |
by AnomalousMonk (Archbishop) on Apr 19, 2009 at 16:58 UTC | |
|
Re: _ in a number within quotes
by linuxer (Curate) on Apr 19, 2009 at 16:40 UTC | |
|
Re: _ in a number within quotes
by moritz (Cardinal) on Apr 19, 2009 at 15:48 UTC |