title: Perl accessing the elements in a hash/hash reference data structure
body: <p>I have a question I'm hoping you could help with as I am new to hashes and hash reference stuff?</p>
  
  <p>I have the following data structure:</p>
  
  <pre><code>$VAR1 = {
      'http://www.superuser.com/' =&gt; {
          'difference' =&gt; {
              'http://www.superuser.com/questions' =&gt; '10735',
              'http://www.superuser.com/faq' =&gt; '13095'
          },
          'equal' =&gt; {
              'http://www.superuser.com/ ' =&gt; '20892'
          }
      },
      'http://www.stackoverflow.com/' =&gt; {
          'difference' =&gt; {
              'http://www.stackoverflow.com/faq' =&gt; '13015',
              'http://www.stackoverflow.com/questions' =&gt; '10506'
          },
          'equal' =&gt; {
              'http://www.stackoverflow.com/ ' =&gt; '33362'
          }
      }
  </code></pre>
  
  <p>If I want to access all the URLs in the key <code>'difference'</code> so I can then perform some other actions on the URLs, what is the correct or preferred method of accessing those elements?</p>
  
  <p>e.g I will end up with the following URLs that I can then do stuff to in a <code>foreach</code> loop with:</p>
  
  <pre><code>http://www.superuser.com/questions
  http://www.superuser.com/faq
  http://www.stackoverflow.com/faq
  http://www.stackoverflow.com/questions
  </code></pre>
  
  <p>------EDIT------</p>
  
  <p>Code to access the elements further down the data structure shown above:</p>
  
  <pre><code>my @urls;
  foreach my $key1 ( keys( %{$VAR1} ) ) {
      print( "$key1\n" );
      foreach my $key2 ( keys( %{$VAR1-&gt;{$key1}} ) ) {
          print( "\t$key2\n" );
      foreach my $key3 ( keys( %{$VAR1-&gt;{$key1}{$key2}} ) ) {
          print( "\t\t$key3\n" );
      push @urls, keys %{$VAR1-&gt;{$key1}{$key2}{$key3}};
      }
    }
  }
  print "@urls\n";
  </code></pre>
  
  <p>Using the code above why do I get the following error?</p>
  
  <p><code>Can't use string ("13238") as a HASH ref while "strict refs" in use at ....</code></p>