in reply to Re: Re: Re: A list returns its last, an array returns its weight
in thread A list returns its last, an array returns its weight

In list context, a comma-separated group of expressions is a list.
... as long as the CSGoE is surrounded by parens e.g
my @foo = "one", "two", "three"; my @bar = ("one", "two", "three"); print @foo, $/, @bar, $/; __output__ one onetwothree
Otherwise it's just a CSGoE :)
HTH

_________
broquaint

update: ignore me, I'm wrong
broquaint goes off to study perlop

  • Comment on Re: Re: Re: Re: A list returns its last, an array returns its weight
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: A list returns its last, an array returns its weight
by japhy (Canon) on Nov 13, 2002 at 16:45 UTC
    The line my @foo = "one", "two", "three"; has three things going on. The first is an assignment to an array (in list context), and the other two are constant strings (in void context).

    "," is an operator. It has a lower precedence than "=". So the expressions "one", "two", "three" aren't in list context.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;