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

Well, it's that lists don't exist in scalar context.

In scalar context, a comma-separated group of expressions is a bunch of comma operators doing their thing. In list context, a comma-separated group of expressions is a list.

_____________________________________________________
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:??;

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

Replies are listed 'Best First'.
Re: Re: Re: Re: A list returns its last, an array returns its weight
by broquaint (Abbot) on Nov 13, 2002 at 16:33 UTC
    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

      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:??;

So is there a list context?
by princepawn (Parson) on Nov 13, 2002 at 17:26 UTC
    I thought the contexts were SCALAR and ARRAY. I did not know where was a list context. Oh, hold it, just because the function is called wantarray one cannot assume that is checking for array context. Sigh.

    Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

      The last sentence of perldoc -f wantarray reads:
      This function should have been named wantlist() instead.

      Abigail