First, a deep thank you to tilly for the meditation on arrays and lists. It was the starting point for the experiments below. Second,I would like to comment that filehandles, even when placed in a list context, do not return their last element:
$file_line = (<DATA>);
while return the first element in the file, even though logically it should return the last. Third, a rhyme to facilitate remembering the behavior of lists and arrays. Lists return last Arrays return their weight (# elements).

Replies are listed 'Best First'.
RE: Arrays and Lists
by merlyn (Sage) on Aug 07, 2000 at 19:01 UTC
    Hmm. You aren't putting a filehandle read operation (not a filehandle) in a list context. You're putting it into a scalar context. Notice:
    $a = THIS_IS_IN_SCALAR; $a = (THIS_IS_STILL_IN_SCALAR); @b = THIS_IS_IN_LIST; @b = (THIS_IS_STILL_IN_LIST);
    It's not the presence of parens on the right that matters. It's the context of the assignment operator, which is determined by the type of the object on the left side.

    And a filehandle read in a scalar context returns one item. If there had been a comma on the right, as in:

    $a = ($x, $y, <DATA>);
    then it still would have been in scalar context, reading only one item. Because now we have a comma (sequential expression evaluation) operator, not a list-building comma.

    This is perhaps not intuitive on first cut, but it's entirely consistent with reading the operations "from outside in", and knowing that parens aren't really doing anything here but providing precedence management.

    -- Randal L. Schwartz, Perl hacker

      So it seems that commas can be list-building ops or sequential expression evaluation ops. And it seems that parentheses can be list constructors or explicit precedence controllers.