title: perl - Math with duplicate entries in array
body: <p>I have two arrays:</p>
  
  <pre><code>my @name = (bob, bob, dave, john, john, mary, mary, mary);
  my @cost = (5, 7, 4, 4, 4, 6, 3 , 4);
  </code></pre>
  
  <p>I want to map them together so the output would just be:</p>
  
  <pre><code>bob 12
  dave 4
  john 8
  mary 13
  </code></pre>
  
  <p>The array's change though so I can't use references. How do I group <code>@cost</code> by <code>@name</code> and add the values of <code>@cost</code>?</p>