This is a precedence problem. You need to put parentheses around the ($n1 + $n2).
Otherwise, Perl adds the result of concatenating the string "$n1 plus $n2 is " with $n1 — i.e.the string "4 plus 2 is 4" — with $n2. This string numerically evaluates to the initial 4, so you do get the result 6.
In reply to Re: This is odd.
by almut
in thread This is odd.
by JDelmoso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |