title: Hashing multiple values to a key in perl
body: <p>I'm reading in a file of words and need to hash words to a key if they are anagrams. So if I read in dog, I sort the word to become dgo. And this would be my key. So I read in the word god, it would be sorted to dgo as well and they should both hash to the same key. </p>
  
  <p>Here is what I am trying but I am not sure if I am doing this correctly. </p>
  
  <pre><code>    if(exists $hash{$string})
      {
              @values2 = $hash{$string};
              push @values2, $original; 
  
              for my $word (@values2)
              {
                  print $word."\n";
              }
              #print "Hello";
      } 
  
      else
      {
           @values = ();
          $hash {$string} = @values;  
          push @values, $string; 
      }   
  }
  </code></pre>
  
  <p>So the <code>$string</code> is my sorted word, the key. So if the key doesn't exist, i create a new array at that key for my $hash. i then push the orginal word into the array. But if the key already exists, I then get the array from the hash and push or add the next word. </p>
  
  <p>But this isn't working properly. Can I not do this?</p>