in reply to Re^2: Scalar Vs. List context
in thread Scalar Vs. List context

Hmmm.
use strict; use warnings; sub foo { print "wantarray? ", wantarray?1:0, "\n"; return wantarray? (1,2,3) : 's-s-sc-scalar'; } my @x =('a','b', foo(), 'c'); print "\@x=(@x)\n";

prints

wantarray? 1 @x=(a b 1 2 3 c)

Looks like list context to me.

Best,beth

Replies are listed 'Best First'.
Re^4: Scalar Vs. List context
by ikegami (Patriarch) on Jul 12, 2009 at 12:07 UTC

    You only showed that it can be evaluated in list context. Why did you ignore my snippet which showed how it can be called in scalar and void context?

    sub foo { print "wantarray? ", wantarray?1:0, "\n"; } my @x =(foo(),foo(), foo()); my $x =(foo(),foo(), foo());
    wantarray? 1 wantarray? 1 wantarray? 1 wantarray? 0 wantarray? 0 wantarray? 0