On Fri, Apr 25, 2003 at 12:08:33AM -0400, Rick Delaney wrote: > On Thu, Apr 24, 2003 at 10:48:36PM -0400, Mark Jason Dominus wrote: > > Rick Delaney <rick.delaney@rogers.com>: > > > > > > Should these be different? > > > > > > my $rv2 = ('a', 'b', 'c', f()); > > > my $rv2 = ('a', 'b', 'c', ); > > > sub f { () } > > > > Yes. > > > > This > > > > my $rv2 = ('a', 'b', 'c', f()); > > sub f { () } > > > > is identical to this: > > > > my $rv2 = ('a', 'b', 'c', f()); > > sub f { } > > > > because the empty parentheses don't matter. > > They're not identical at the opcode level because the parentheses do > matter, since they create a stub expression that returns undef in scalar > context. Right. A list in a scalar context evaluates each element in a scalar context before any flatening is done. sub f { warn wantarray ? 1 : 0; return } @a = ('a', f(),''); $a = ('a', f(),''); __END__ 1 at - line 1. 0 at - line 1. () in a scalar context yeilds undef. Graham.Thread Previous | Thread Next