title: How to pass value of a hash of arrays into a subroutine?
body: <p>I have a hash of arrays. I'm trying to do the following: as I'm looping through the keys of the hash, I would like to pass the value of the hash (in this case the array) into a subroutine.</p>
  
  <p>Once I'm in the subroutine, I'd like to do a bunch of calculations with the array including take the average of the numeric values in the array. Lastly return a value based on the calculations.</p>
  
  <p>Here's a minimal representation of what I have:</p>
  
  <pre><code>#!/usr/bin/perl
  use warnings; use strict;
  use List::Util qw(sum);
  
  %data_set = (
      'node1' =&gt; ['1', '4', '5', '2'],
      'node2' =&gt; ['3', '2', '4', '12'],
      'node3' =&gt; ['5', '2', '3', '6'],
      );
  
  foreach my $key ( keys %data_set ) {
      foreach ( @{$data_set{$key}} ) {
          my @array = split;   # it's not letting me 
          calculate(\@array);   ### I'm getting the error here!!
      }
  }
  
  sub calculate{
      my @array = @{$_};
      my $average = mean(\@array);
      # do some more calculations
      return; # return something
  }
  
  # sum returns the summation of all elements in the array
  # dividing by @_ (which in scalar content gives the # of elements) returns
  # the average
  sub mean{
      return sum(@_)/@_;
  }
  </code></pre>
  
  <p>Quick clarification: On the first iteration <code>node1</code>, I'd like to pass the array <code>'1', '4', '5', '2'</code> into the subroutine.</p>
  
  <p>I think for my purposes this might be a bit more efficient than passing a reference to the hash of arrays into each subroutine. What do you guys think? In any case, can you guys help me figure this out? Any suggestions are appreciated. thanks</p>