title: dereferencing a nested hash in perl
body: <pre><code>#!/usr/bin/perl
  
  use strict;
  use warnings;
  
  my %ani_hash = (
      'machine_results' =&gt; [
          {
              'status'  =&gt; 'Failed install',
              'machine' =&gt; '23.73.134.235',
              'seconds' =&gt; '20',
              'try'     =&gt; '1'
          },
          {
              'status'  =&gt; 'Failed install',
              'machine' =&gt; '23.73.134.140',
              'seconds' =&gt; '20',
              'try'     =&gt; '1'
          }
      ],
      'description' =&gt; 'MC-5897'
  );
  
  get_elements( \%ani_hash );
  
  sub get_elements
  {
      my $hashref1 = shift;
  
      my %hashref2 = %$hashref1;
      print "%hashref1\n";
  
      foreach my $machineresult ( keys %hashref2 ) {
          foreach my $machineresult2 ( keys %{ $hashref2{$machineresult} } ) {
              print "$hashref2{$machineresult}{$machineresult2}\n";
          }
      }
  }
  
  Output: 
  
      HASH(0x1e9fe58)
      Not a HASH reference at ./hashref.pl line 62.
      Can't use string ("MC-5897") as a HASH ref while "strict refs" in use at ./hashref.pl line 62.
  </code></pre>
  
  <p>I want to loop through all the key value pairs and get their values.
  I don't want to use the dumper method to get the values, I want to get these by looping method. Any help would be appreciated. Thanks </p>
  
  <p>I did this to fix the issue and get the contents of 'machine_results'.</p>
  
  <pre><code>print "description: $hashref2{description}\n";
  
  foreach my $machineresult( sort keys%hashref2){
      foreach my $array (@{ $hashref2{$machineresult} }){
          foreach my $array1( sort keys%{$array} ){
              print "key is $array1 and it's value is $array-&gt;{$array1}`",
                    "enter code here`\n";    
          }
          print "\n";
      }
  }
  </code></pre>