Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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]

Output:

HASH(0x27ee58)

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

Output:

Santa Claus


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2015-07-28 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (253 votes), past polls