Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: hash within an array within a hash

by Kenosis (Priest)
on Sep 07, 2012 at 01:48 UTC ( #992220=note: print w/ replies, xml ) Need Help??

in reply to hash within an array within a hash

You have the following line in your script:

my $ownersRef = [ $owner1Ref, $owner2Ref ];

A two-element anonymous array is created, and $ownersRef is a reference to it. To get at the element 0 of this array, the arrow operator can be used to deference the array reference:

print $ownersRef->[0]



Element 0 in the anonymous array is a hash reference (and so is element 1). So, to get "Santa Claus" (sounds like a movie plot, doesn't it???!), another arrow operator can be used for dereferencing the hash reference:

print $ownersRef->[0]->{name}; ^ ^ | | | + hash key for "Santa Claus" | + array element 0


Santa Claus
Comment on Re: hash within an array within a hash
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2016-04-29 02:31 GMT
Find Nodes?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW

    Results (438 votes). Check out past polls.