$ perl -wle' my %h = (a => 23, b => 24, c => 25); print "while"; while (my ($k, $v) = each %h) { print "$k => $v"; } print "for"; for (my ($k, $v) = each %h) { print "$k => $v"; } ' while c => 25 a => 23 b => 24 for c => 25 c => 25