in reply to Re^2: Possible for Map to create Hash of Hash?
in thread Possible for Map to create Hash of Hash?

> couldn't be sure if it was possible.

Well, I think the point is that map isn't primarily meant to operate on hashes, it takes a list and returns a list.

LIST = map {BLOCK} LIST

But assigning a list to a hash can result in collisions

DB<166> %hash = (Canberra => { 12 => 1}, Canberra => { 18 => 1} ) => ("Canberra", { 18 => 1 })

You could however design a sub join_deep , such that:

DB<178> sub join_deep { my %hash; while ( my ($a,$b) = splice @_,0,2 ) { $hash{$a}= { %{$hash{$a}}, %$b } } return %hash; } DB<179> %h =join_deep (Canberra => { 12 => 1}, Canberra => { 18 => 1 +} ) => ("Canberra", { 12 => 1, 18 => 1 })

But frankly, I don't see the need for such abstraction.

Cheers Rolf

( addicted to the Perl Programming Language) couldn't be sure if it was possible.