title: Perl How do I retrieve an array from a hash of arrays?
body: <p>I'm fairly new to Perl, so forgive me if this seems like a simple question...</p>
  
  <p>Anyway, I have a hash of arrays and I'm trying to retrieve one of the arrays in the hash, but all I can get is the scalar size of the array.</p>
  
  <pre><code>%HoA = a hash of arrays
  $key = some key in the hash
  
  foreach $nextItem (@HoA{$key}) {
    do a bunch of stuff with $nextItem
  }
  </code></pre>
  
  <p>When I do this, $nextItem is always just the size of the array and the loop only runs through one time.  I've tried printing the following:</p>
  
  <pre><code>@HoA{$key}
  $HoA{$key}
  @$HoA{$key}
  </code></pre>
  
  <p>The first two give me the scalar size and the third gives me nothing...what am I missing here?</p>
  
  <p>UPDATE:  I'm wondering if my problem is actually the way I'm adding the arrays to the hash.  Here's what I'm doing:</p>
  
  <pre><code>@HoA{$key} = split(/ /, $list);
  </code></pre>
  
  <p>Does that stick the array in the hash, or the array size in the hash?</p>
  
  <p>UPDATE 2: I tried the following block of code:</p>
  
  <pre><code>my $key = "TEST";
  my %HoA = ();
  my @testarray = (1, 2, 3);
  @HoA{$key} = @testarray;
  print Dumper(%HoA);
  </code></pre>
  
  <p>Here's the output:</p>
  
  <pre><code>$VAR1 = 'TEST';
  $VAR2 = 1;
  </code></pre>
  
  <p>Why is it only sticking the first value of the array in?</p>