Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to address hashtables nested in arrays?

by pme (Monsignor)
on Apr 11, 2015 at 20:59 UTC ( [id://1123156]=note: print w/replies, xml ) Need Help??


in reply to How to address hashtables nested in arrays?

Hi benedicth,

You can access the values this way:

foreach my $n (@{$data->{instance}}) { foreach my $m (@{$n->{contact}}) { foreach my $key (keys %{$m}) { print "key: $key -> $m->{$key}\n"; } } }

Replies are listed 'Best First'.
Re^2: How to address hashtables nested in arrays?
by benedicth (Initiate) on Apr 11, 2015 at 21:07 UTC
    Thank you so much!! I'm still a newbie can you tell me why %{$data->{$m} does not work in this case?
      In this case both $n and $m contain hash reference but in %{$data->{$m}} $m should be a key.

      Try to run your script in perl debugger (perldebug) and check $n and $m using 'x' command for better understanding.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found