in reply to comma-operator quirks
My interpretation.
Perl interprets lists, including function parameter lists, left to right.
It first evaluates $a=3 & "\n", then it attempts to evaluate the third argument, which is the second print.
So now it has to evaluate it's parameters ($a-5 & "\n") and gets (-2, chr(10)) and passes these to print.
print outputs them, and returns true (1).
It now has the values of the arguments to the first print (3,chr(10),1), so it passes them.
print outputs these and returns true to a void context.
And perls interpretation
perl58 -MO=Deparse,-p -e"print $a=3, $/, print $a-5, $/" print(($a = 3), $/, print(($a - 5), $/)); -e syntax OK
|
|---|