= and , operators in Perl -
please explain apparently inconsistent behaviour:
$a = b, c; print $a; # prints: b $a = (b, c); print $a; # prints: c
as eugene's answer seems leave questions op try explain based on that:
$a = "b", "c"; print $a; here left argument $a = "b" because = has higher precedence , evaluated first. after $a contains "b".
the right argument "c" , returned show soon.
at point when print $a printing b screen.
$a = ("b", "c"); print $a; here term ("b","c") evaluated first because of higher precedence of parentheses. returns "c" , assigned $a.
so here print "c".
$var = ($a = "b","c"); print $var; print $a; here $a contains "b" , $var contains "c".
once precedence rules perfectly consistent
Comments
Post a Comment