for (1..2) { while (($k,$v) = each %hash) { do_something_with($k, $v); } }