while(($key, $msg) = each %$msg) { process_msg($bs,$msg); } #### while(($key, $msg) = each %$record) #### foreach my $msg (values %$records) { process_msg($bd, $msg); }