while (my ($key, $value) = each %my_hash) { . . # some processing on the element . } #### for my $key (keys %my_hash) { my $value = $my_hash{$key} # and no need to change the code below . . # some processing on the element . } #### for my $key (my @temp = keys %my_hash) { my $value = $my_hash{$key} # and no need to change the code below . . # some processing on the element . }