= and , operators in Perl
perl
Solution
As eugene's answer seems to leave some questions by OP i try to explain based on that:
$a = "b", "c";
print $a;
Here the left argument is `$a = "b"` because `=` has a higher precedence than `,` it will be evaluated first. After that `$a` contains `"b"`.
The right argument is `"c"` and will be returned as i show soon.
At that point when you print `$a` it is obviously printing `b` to your screen.
$a = ("b", "c");
print $a;
Here the term `("b","c")` will be evaluated first because of the higher precedence of parentheses. It returns `"c"` and this will be assigned to `$a`.
So here you print `"c"`.
$var = ($a = "b","c");
print $var;
print $a;
Here `$a` contains "b" and `$var` contains "c".
Once you get the precedence rules this is perfectly consistent
Problem
Please explain this apparently inconsistent behaviour: ``` $a = b, c; print $a; # this prints: b $a = (b, c); print $a; # this prints: c ```