title: perl hash of hash of arrays with looping
body: <p>I have the following data in a hash of hash of arrays.  The numerical data in the array represents that last 4 quarters of financial information.</p>
  
  <p>I'd like to be able to iterate over the array, and pull out the data by quarter, to get it ready to insert into a database.  With my code below I can get all of the quarters, or one quarter only if I specifically call it.  When I try and add another loop to iterate over the hash of hash of arrays to return only the array subset values, i get all the values and I don't know what I'm doing wrong.  See code:  Thanks for the help</p>
  
  <pre><code>my %comp_info = (
    CompanyA =&gt; {
      COGS    =&gt; ["175.00", "155.00", "125.00", "125.00"],
      Revenue =&gt; ["300.00", "200.00", "250.00", "225.00"],
    },
  )
  </code></pre>
  
  <p></p>
  
  <pre><code># The following works, but I have to specifically push one array subset at a time, 
  # which makes passing values to db_insert subroutine ineffective.  
  # (Id have to have 4 or 5 calls depending on number of quarters of data in each record).
  
  sub get_insert_arrays {
    foreach $comp (keys %comp_info ) {
       foreach $column ( keys %{$comp_info{$comp}} ) {
          push (@insert_array, @{$comp_info{$sym}{$column}}[0] );
       }
    }
    my $valuelist = join(", ", @insert_array);
    &amp;db_insert($valuelist);
    undef @insert_array;
  }
  </code></pre>
  
  <p></p>
  
  <pre><code>#try to loop through, fails, I get all of the data in @insert_array instead of only one quarter.
  sub get_insert_arrays {
    foreach $comp (keys %comp_info ) {
       foreach $column ( keys %{$comp_info{$comp}} ) {
          for my $i ( 0 .. $#{$comp_info{$comp}{$column}} ) {
             push (@insert_array, @{$comp_info{$sym}{$column}}[$i] ); 
          }
       }
      my $valuelist = join(", ", @insert_array);
      &amp;db_insert($valuelist);
      undef @insert_array;  
      undef $valuelist;   
    }
  }
  </code></pre>