1: foreach my $key (%hash) { 2: print $key; 3: delete $hash{$key}; 4: }