title: how to sum values from hash based on keys from a different hash?
body: <p>Not sure if that's even the right title for this question as I'm new to Perl, but I have a text file with 2 columns of interest:</p>
  
  <pre><code>AB      Volume
  100     280
  137     250
  150     375
  100     100
  100     600
  137     200
  </code></pre>
  
  <p>And I want to sum up Volumes based on AB#, the resulting output being</p>
  
  <pre><code>AB     Instances     Volume
  100    3              980
  137    2              450
  150    1              375
  </code></pre>
  
  <p>All I've done till now is to display distinct AB's in the output file, but I'm struggling to get the sum of Volume counts.</p>
  
  <pre><code>$isAB{$AB} = 1;
  $isVolume{$Volume} =1;
  $numAB{$AB}++;
  
  print "AB\tInstances\tVolume\n";
  for $AB (sort {$a&lt;=&gt;$b;} keys %numAB) {
          print "$AB\t$numAB{$AB}\n";
  }
  </code></pre>
  
  <p>Any help will be appreciated! Thanks</p>