title: Storing multiple values in one key in a hash of hash using Perl
body: <p>I am trying to create a data structure to store data I am pulling off a database:</p>
  
  <pre><code>$Interaction{$TrGene}={
  CisGene =&gt; $CisGene,
  E =&gt; $e,
  Q =&gt; $q,};
  </code></pre>
  
  <p>A single $TrGene is associated to a number of CisGenes (which has a unique E &amp;Q).
  e.g:</p>
  
  <p>TrGene1 CisGene1 Q1 E2</p>
  
  <p>TrGene1 CisGene2 Q2 E3</p>
  
  <p>The last TrGene1 overwrites those that came before it. I think that I need to create a reference to an array, but don't fully understand how this should be done after reading this webpage:  <a href="http://perldoc.perl.org/perlreftut.html" rel="nofollow">http://perldoc.perl.org/perlreftut.html</a></p>
  
  <p>I have attempted to use the country/city example on that webpage, but have not been very successful:</p>
  
  <pre><code>$Interaction{$TrGene}={
  CisGene =&gt; $CisGene,
  E =&gt; $e,
  Q =&gt; $q,};
  push @{$Interaction{$TrGene}}, $CisGene;
  </code></pre>
  
  <p>I get an error 'Not an ARRAY ref'. I have also only used $CisGene there, however it needs to not overwrite the E &amp; Q values for that CisGene. (so will this hash know that the CisGene is associated to a specific E and Q, or do I need to create another layer of hash for that?)</p>
  
  <p>Thanks</p>