in reply to Re: Scalar Vs. List context
in thread Scalar Vs. List context
array and list elements: these are implicitly in list context.
Not true. Every expression can be evaluated in any context. The context in which the expression is evaluated is determined by the operator to which the expression is an operand.
Expressions that are list elements are no exception. The list operator decides the context of its operands based on its context:
@a = (1,2,3,4); # list, list, list, list $a = (1,2,3,4); # void, void, void, scalar
Expressions that are arrays are no exception.
@b = @a; # @a is evaluated in list context. $c = @a; # @a is evaluated in scalar context. @a; 1; # @a is evaluated in void context.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Scalar Vs. List context
by jwkrahn (Abbot) on Jul 12, 2009 at 12:52 UTC | |
by ikegami (Patriarch) on Jul 13, 2009 at 15:17 UTC | |
by Anonymous Monk on Jul 12, 2009 at 12:55 UTC | |
by jwkrahn (Abbot) on Jul 12, 2009 at 13:12 UTC | |
| |
|
Re^3: Scalar Vs. List context
by ELISHEVA (Prior) on Jul 12, 2009 at 07:35 UTC | |
by ikegami (Patriarch) on Jul 12, 2009 at 12:07 UTC |