"Perl Programmers Reference Guide (англ.) (программ.) /19.12.1998/ " - читать интересную книгу автора




16 perl 5.005, patch 02 14/Jun/98





PERLDATA(1) Perl Programmers Reference Guide PERLDATA(1)


evaluated in a list context, and the resulting list value
is interpolated into LIST just as if each individual
element were a member of LIST. Thus arrays and hashes
lose their identity in a LIST--the list

(@foo,@bar,&SomeSub,%glarch)

contains all the elements of @foo followed by all the
elements of @bar, followed by all the elements returned by
the subroutine named SomeSub called in a list context,
followed by the key/value pairs of %glarch. To make a
list reference that does _N_O_T interpolate, see the _p_e_r_l_r_e_f
manpage.

The null list is represented by (). Interpolating it in a
list has no effect. Thus ((),(),()) is equivalent to ().
Similarly, interpolating an array with no elements is the
same as if no array had been interpolated at that point.

A list value may also be subscripted like a normal array.
You must put the list in parentheses to avoid ambiguity.
For example:

# Stat returns list value.
$time = (stat($file))[8];

# SYNTAX ERROR HERE.
$time = stat($file)[8]; # OOPS, FORGOT PARENTHESES

# Find a hex digit.
$hexdigit = ('a','b','c','d','e','f')[$digit-10];

# A "reverse comma operator".
return (pop(@foo),pop(@foo))[0];

You may assign to undef in a list. This is useful for
throwing away some of the return values of a function: