title: count the number of keys that map to a value
body: <p>I have the following hash</p>
  
  <pre><code>my %hash = (
      w1 =&gt; '0',
      e2 =&gt; '1',
      r1 =&gt; '2',
      o3 =&gt; '1',
      h4 =&gt; '0',
      t5 =&gt; '1',
  );
  </code></pre>
  
  <p>I would like to get the number of keys that map to each value in the hash. </p>
  
  <pre><code>3 keys map to value 1.
  1 key map to value 2.
  2 keys map to value 0.
  </code></pre>
  
  <p>I would like to do this without using a function from a module. </p>
  
  <p>One way I thought of doing this was looping through the values of the hash. If that value has a key then increment the counter for that key. The problem is knowing what the values are beforehand so that I can initialize counters for each value. There's probably an easier solution to this. I think regex might work.</p>
  
  <p>attempt 1</p>
  
  <pre><code>my $string;
  foreach my $value (value %hash) {
  $string = join(",", $value);
  }
  
  # count the number of occurrences for each value (separated by commas)
  </code></pre>