while( my $k = each %hash ) { ... } foreach my $k ( keys %hash ) { ... } #### while( my ( $k, $v ) = each %hash ) { #### foreach my $k ( keys %hash ) { my $v = $hash{ $k }; #### sub each_iter(%) { my $hash = shift; my @keys = keys %$hash; sub { my $nkey = shift @keys; $nkey => $hash->{$nkey}; } } my $iter = each_iter %some_hash; while( my ( $k, $v ) = $iter->() ) {