title: How to get the number of keys in a perl hash of hashes?
body: <p>I want to get the number of entries for each group, but it seems to be giving me the wrong answer.  There are elements in each group that might be repeated.  The results I'm getting don't make sense. What am I doing wrong?</p>
  
  <pre><code>my %hash;
  while(&lt;&gt;)
  {
      chomp($_);
      if(/(\d+)\t(\d+)/)
      {
          my $group = $1;
          my $element = $2;
          $hash{$group}{$element}=1;
      }
  }
  
  foreach my $curr(keys %hash)
  {
      my $numElementsInCurr = keys %{$hash{$curr}};
      print "$curr\t$numElementsInCurr\n";
  }
  </code></pre>