in reply to Re^4: wantarray - surprise behaviour
in thread wantarray - surprise behaviour

No, the list *doesn't* come from the comma. It comes from the assignment:
sub foo { $c = wantarray; print $c ? "A" : defined $c ? "S" : "V" } (foo(), foo(), foo()); print "\n"; $v = (foo(), foo(), foo()); print "\n"; @v = (foo(), foo(), foo()); print "\n"; __END__ VVV VVS AAA

Replies are listed 'Best First'.
Re^6: wantarray - surprise behaviour
by diotalevi (Canon) on Sep 01, 2004 at 17:43 UTC

    Well, no. That's a case of a list in scalar or list context. I quote from perlop about the assignment operator.

    a list assignment in list context produces the list of lvalues assigned to, and a list assignment in scalar context returns the number of elements produced by the expression on the right hand side of the assignment.