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

I'm not sure it even gets to the point of evaluation :-). At least in Perl 5.8.8 attempts to pass a first parameter without an @ sigal produces compilation errors. You don't even need strictures to produce them:
our @x; sub foo { print "wantarray? ", wantarray?1:0, "\n"; push @x, (1,2,3); return @x; } pop foo();

generates

Type of arg 1 to pop must be array (not subroutine entry) at Monks/Sni +ppet.pm line 7, near ");" Execution of Monks/Snippet.pm aborted due to compilation errors.

The same compilation error results if one tries to use a subroutine to generate the first parameter of push as well. Replacing pop foo() with push foo(), 4 results in

Type of arg 1 to push must be array (not subroutine entry) at Monks/Sn +ippet.pm line 7, near "4;" Execution of Monks/Snippet.pm aborted due to compilation errors.

Best, beth

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

    I'm not sure it even gets to the point of evaluation :-).

    Are you saying it's a no-op?

    push @{[ print "It definitely gets evaluated" ]}, 1;

    To revisit what I already said, it's useless to talk about the context in which the @a from push @a, ... is evaluated because it doesn't return what it normally returns in either list or scalar context.