in reply to map into a multidimensional hash
my %hash = map +($_->{id_1} => { $_->{id_2} => $_->{v} }), @aoh;
Otherwise, you need to assign to the inner hash not to overwrite a previous branch.
Tried with
my @aoh = ( { id_1 => "F1", id_2 => "F2", v => "FV" }, { id_1 => "S1", id_2 => "S2", v => "SV" }, { id_1 => "T1", id_2 => "T2", v => "TV" }, { id_1 => "T1", id_2 => "T3", v => "TW" }, );
Another approach would be to use Data::Diver:
use Data::Diver qw{ DiveVal }; my %hash; DiveVal(\%hash, @$_{qw{ id_1 id_2 }}) = $_->{v} for @aoh;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: map into a multidimensional hash
by Eily (Monsignor) on Mar 09, 2017 at 12:40 UTC | |
|
Re^2: map into a multidimensional hash
by LanX (Saint) on Mar 09, 2017 at 20:09 UTC |