my $joined_keys = [ keys( %{ { map { $_=>undef } keys( %{$hash1} ) , keys( %{$hash2} ) } } ) ]; # This.....^............................................................^ *is a hash* built from #...............................^^^^^^^^^^^^^^^^^...^^^^^^^^^^^^^^ #...the combined (potentially huge) lists of the keys from both hashes PLUS #.....................^^^^^...undef as the value for each key in the combined list...