title: Why doesn't Perl's each() iterate through the entire hash the second time?
body: <p>I have a simple script trying to learn about hashes in Perl. </p>
  
  <pre><code>#!/usr/bin/perl
  
  my %set = (
      -a =&gt; 'aaa',
      -b =&gt; 'bbb',
      -c =&gt; 'ccc',
      -d =&gt; 'ddd',
      -e =&gt; 'eee',
      -f =&gt; 'fff',
      -g =&gt; 'ggg'
  );
  
  print "Iterate up to ggg...\n";
  while ( my ($key, $val) = each %set ) {
      print "$key -&gt; $val \n";
      last if ($val eq 'ggg');
  }
  print "\n";
  
  print "Iterate All...\n";
  while ( my ($key, $val) = each %set ) {
      print "$key -&gt; $val \n";
  }
  print "\n";
  </code></pre>
  
  <p>I am surprised by the output:-</p>
  
  <pre><code>Iterate upto ggg...
  -a -&gt; aaa
  -c -&gt; ccc
  -g -&gt; ggg
  
  Iterate All...
  -f -&gt; fff
  -e -&gt; eee
  -d -&gt; ddd
  -b -&gt; bbb
  </code></pre>
  
  <p>I understand that the keys are hashed so the first output can be 'n' elements depending on the internal ordering. But why am I not able to just loop the array afterward? What's wrong ? </p>
  
  <p>Thanks,</p>