while (($k,$v) = each %first) { $union{$k} = $v; } while (($k,$v) = each %second) { $union{$k} = $v; }