my %h = map { $_ => 1 } qw( a b c d ); while (my $k = each(%h)) { last; } keys(%h); while (my $k = each(%h)) { print("$k\n"); # c a b d }