in reply to How to transform a matrix into a hash??
IMO, Data::Diver is definitely the way to go here. No fuss, no muss - just DWIMery.
use strict; use warnings; use Data::Diver qw( DiveVal ); use Data::Dumper; my $aokeys = [ [ 'a', 'b', 'c' ], [ 'a', 'b', 'd' ], [ 'b', 'b', 'b' ], ]; my $href = {}; foreach my $key_aref ( @$aokeys ) { DiveVal( $href, @$key_aref ) = 1; } print Dumper $href;
$VAR1 = { 'a' => { 'b' => { 'c' => 1, 'd' => 1 } }, 'b' => { 'b' => { 'b' => 1 } } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to transform a matrix into a hash??
by yocoim (Initiate) on Feb 06, 2008 at 19:47 UTC |