foreach my $href (values %tmp) { $animals{$_} = $href->{data} foreach keys %{$href->{variations}} }