title: Perl: Hash ref accessing array of keys
body: <p>I have a question that seems basic, but I can't figure out. Say that I have a hash reference in Perl. I want to get an array of values through an array of keys. </p>
  
  <p>Here's how it'd work with a hash, not a hash reference:</p>
  
  <pre><code>my %testHash = ( "a" =&gt; 1, "b" =&gt; 2, "c" =&gt; 3 );
  my @testKeys = ("a", "b", "c");
  
  my @testValues = @testHash{@testKeys};
  </code></pre>
  
  <p>Now suppose I have a hash reference,</p>
  
  <pre><code>my $hashRef = {"a" =&gt; 1, "b" =&gt; 2, "c" =&gt; 3};
  </code></pre>
  
  <p>I've tried the following two ways:</p>
  
  <pre><code>my @values = @{$hashRef-&gt;{@testKeys}};
  my @values = $hashRef-&gt;{@testKeys};
  </code></pre>
  
  <p>But neither is correct. Is there a correct way, or do I just have to dereference the hash ref every time I want to do this?</p>