my $x = { 1 .. 40000 }; for (1 .. 3 ) { my $k; while ($k = each %$x) { last; } %$x = %$x; print "$k\n"; }