- 论坛徽章:
- 0
|
回复 4# MMMIX
List value constructors
List values are denoted by separating individual values by commas (and enclosing the list in parentheses where
precedence requires it):
(LIST)
In a context not requiring a list value, the value of what appears to be a list literal is simply the value of the
final element, as with the C comma operator. For example,
@foo = ('cc', '-E', $bar);
assigns the entire list value to array @foo, but
$foo = ('cc', '-E', $bar);
assigns the value of variable $bar to the scalar variable $foo. Note that the value of an actual array in scalar
context is the length of the array; the following assigns the value 3 to $foo:
@foo = ('cc', '-E', $bar);
$foo = @foo; # $foo gets 3
|
|