nikmit has asked for the wisdom of the Perl Monks concerning the following question:
I guess this is not possible by design, but just in case I am missing something...
Is there a clever/efficient way to make this work (other than with a loop)?
my %hash = map { delete $_->{id_1} => { delete $_->{id_2} => $_ } } @ary_of_hrefs;It should produce the same result as the below (except not a reference)
my $hash; foreach my $href (@ary_of_hrefs) { my $id_1 = delete $href->{id_1}; my $id_2 = delete $href->{id_2}; $hash->{$id_1}->{$id_2} = $href; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: map into a multidimensional hash
by choroba (Cardinal) on Mar 09, 2017 at 12:19 UTC | |
by Eily (Monsignor) on Mar 09, 2017 at 12:40 UTC | |
by LanX (Saint) on Mar 09, 2017 at 20:09 UTC | |
|
Re: map into a multidimensional hash
by Eily (Monsignor) on Mar 09, 2017 at 10:38 UTC | |
|
Re: map into a multidimensional hash
by marioroy (Prior) on Mar 09, 2017 at 10:26 UTC | |
|
Re: map into a multidimensional hash
by Discipulus (Canon) on Mar 09, 2017 at 10:21 UTC | |
|
Re: map into a multidimensional hash
by Anonymous Monk on Mar 09, 2017 at 10:06 UTC | |
|
Re: map into a multidimensional hash
by LanX (Saint) on Mar 09, 2017 at 15:17 UTC |