T
truexueweizhong
I'm really confused about the following result:
$ perl -e '@a = (a1,a2); @b = (b1,b2); @c = @a || @b; print @c'
2
-----------seemed to be scalar context
$ perl -e '@a = (a1,a2); @b = (b1,b2); @c = @a or @b; print @c'
a1a2
----------seemed to be list context
what's the rules govering this issue?
the sentence in perlop say it not clearly, only one sentence:
Scalar or list context propagates down to the right operand if
it is evaluated.
and
Logical or and Exclusive Or
Binary "or" returns the logical disjunction of the two
surrounding
expressions. It's equivalent to || except for the very low
precedence.
But what's the explaination of sampling code?
$ perl -e '@a = (a1,a2); @b = (b1,b2); @c = @a || @b; print @c'
2
-----------seemed to be scalar context
$ perl -e '@a = (a1,a2); @b = (b1,b2); @c = @a or @b; print @c'
a1a2
----------seemed to be list context
what's the rules govering this issue?
the sentence in perlop say it not clearly, only one sentence:
Scalar or list context propagates down to the right operand if
it is evaluated.
and
Logical or and Exclusive Or
Binary "or" returns the logical disjunction of the two
surrounding
expressions. It's equivalent to || except for the very low
precedence.
But what's the explaination of sampling code?