On Fri, Dec 14, 2001 at 06:39:02AM +1100, Damian Conway wrote: > > > In the following code fragment, what context is foo() in? > > > > @ary[0] = foo() > > Scalar context. @ary[0] is a single element of @ary. > > To call foo() in list context use any of the following: > > (@ary[0]) = foo(); # Assign @ary[0] the first element returned > @(@ary[0]) = foo(); # " " " " " " > @ary[@(0)] = foo(); # " " " " " " > @ary[0,] = foo(); # " " " " " " > @ary[[0]] = foo(); # " " " " " " > > @ary[0] = @(foo()); # Assign @ary[0] a ref to the elems returned > @ary[0] =()= foo(); # " " " " " " " "
Hm, thats a change from perl5. In perl5 that would assign the number of elements returned from foo(). Is there a good reason for this change ? Graham. > @ary[0] = [foo()]; # " " " " " " " " > > Damian