in reply to Hashes of Hashes with Multidimensional array
# warning windows doublequotes! # Data::Dump is a bit better.. perl -MData::Dump -e "@ar1='A'..'E';@ar2=1..5;@ar3='a'..'e';$hash{shif +t @ar1}={shift @ar2=>shift @ar3} while @ar1; dd %hash" ( "A", { 1 => "a" }, "D", { 4 => "d" }, "C", { 3 => "c" }, "E", { 5 => "e" }, "B", { 2 => "b" }, )
..or, just to learning something, mixing the whole into a single assignement forcing map to return an anonymous hash {$_=>"something"}
perl -MData::Dumper -e "@ar1='A'..'E';@ar2=1..5;@ar3='a'..'e';@hash{@a +r1}=map{{$_=>shift @ar3}}@ar2;print Dumper \%hash" $VAR1 = { 'A' => { '1' => 'a' }, 'D' => { '4' => 'd' }, 'C' => { '3' => 'c' }, 'E' => { '5' => 'e' }, 'B' => { '2' => 'b' } };
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hashes of Hashes with Multidimensional array
by Eshan_k (Acolyte) on Dec 15, 2016 at 20:10 UTC | |
by Anonymous Monk on Dec 15, 2016 at 22:44 UTC | |
by Discipulus (Canon) on Dec 16, 2016 at 08:06 UTC |