in reply to This is odd.
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.
|
|---|