Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Is this a bug, or expected behavior?

by QM (Parson)
on Mar 17, 2006 at 15:19 UTC ( [id://537471]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://537471]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found