<?xml version="1.0" encoding="windows-1252"?>
<node id="989884" title="Re: help to get hash elements" created="2012-08-26 18:13:36" updated="2012-08-26 18:13:36">
<type id="11">
note</type>
<author id="590906">
linuxer</author>
<data>
<field name="doctext">
&lt;p&gt;What about [doc://perldsc#Access-and-Printing-of-a-HASH-OF-HASHES]?&lt;/p&gt;

&lt;p&gt;Simply create a 2-level loop and iterate through the keys of each level.&lt;/p&gt;

&lt;code&gt;
# untested:
my @urls;
for my $outer ( keys %hash ) {
  for my $inner ( keys %{ $hash{$outer} } ) {
    # maybe check before, if entry "url" exists or is defined ...
    push @urls, $hash{$outer}-&gt;{$inner}-&gt;{url};
  }
}
&lt;/code&gt;

&lt;p&gt;&lt;b&gt;update:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;I missed last night that there is an anonymous array inside &lt;c&gt;$hash{$outer}-&gt;{$inner}&lt;/c&gt;; so here's an updated code:

&lt;code&gt;
for my $outer ( keys %hash ) {
    for my $inner ( keys %{ $hash{$outer} } ) {
        push @urls, map { $_-&gt;{url} }  @{ $hash{$outer}-&gt;{$inner} }
    }
}
&lt;/code&gt;
&lt;p&gt;As the other answers point out, if there is only one "outer" and one "inner" key, you can skip the loops and access the inner referenced array directly...&lt;/p&gt;</field>
<field name="root_node">
989881</field>
<field name="parent_node">
989881</field>
</data>
</node>
