Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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: (4)
As of 2014-09-21 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (165 votes), past polls