use experimental "for_list"; foreach my ($key, $value) (%hash) { # iterate over the hash # The hash is immediately copied to a flat list before the loop # starts. The list contains copies of keys but aliases of values. # This is the same behaviour as for $var (%hash) {...} }