title: Is it safe in Perl to delete a key from a hash reference when I loop on the same hash? And why?
body: <p>I basically want to do this:</p>
  
  <pre><code>foreach my $key (keys $hash_ref) {
  
      Do stuff with my $key and $hash_ref
  
      # Delete the key from the hash
      delete $hash_ref-&gt;{$key};
  }
  </code></pre>
  
  <p>Is it safe? And why?</p>