in reply to Re: wantarray - surprise behaviour
in thread wantarray - surprise behaviour
the parens are used for precedence, and nothing else. It's needed because the precedence of the comma operator is lower than the precedence of the assignment operator. List context is given because of the assigment to an aggregate - a hash. If the expression would be:my %hash = (1, blah ());
then blah() will be called in list context, and if the expression would be:my %hash = blah ();
blah() will be called in scalar context.my $scalar = (1, blah ());
What (1, @a) returns depends on the context. In scalar context, the value of (1, @a), with @a a two element array, will be 2.
|
|---|