title: Referencing hash keys with a variable in perl
body: <p>I am trying to create a Perl script that allows me access a hash key/value by using a variable.</p>
  
  <p>The code below is a very high level example of script does. Is there any way to reference the key of the hash with a variable? It looks like the $hash_exmp{$temp_var} is not being accepted.</p>
  
  <pre><code>my %hash_exmp = (
      $key_1 =&gt; "file1",
      $key_2 =&gt; "file2",
      $key_3 =&gt; "file3",
  );
  
  for($i = 1; $i &lt;= 3; $i++){
      for($j = 1; $j &lt;= 3; $j++){     
          print $j;            
          $temp_var = "key_${i}";
          print $hash_exmp{$temp_var};
      };
  };
  </code></pre>