in reply to Is this a bug, or expected behavior?

Tugging at the loose threads some more...
my $b = [ $a->[1,2,3,4] ];
gives a reference to an array with one element, undef.

I'm guessing these are both edge cases in the dereference mechanism (->). Someone with more expertise than myself will have to look at the optree for these.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: Is this a bug, or expected behavior?
by merlyn (Sage) on Mar 17, 2006 at 16:21 UTC
    I would expect $a->[1, 2, 3, 4] to be the same as $a->[4], because the index is being evaluated in a scalar context, which means the comma is a "comma operator" (evaluate left expression, discard it, evaluate right expression). Correct?

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Yes, rigthly so.

      When I first checked this, I must have made a mistake, because it behaves exactly as you indicate.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of