neversaint has asked for the wisdom of the Perl Monks concerning the following question:
doesn't produce the following desired result:use strict; use Data::Dumper; use Carp; my @nar = ( ['fact 1 - ParamGrp1', 'foo', 'bar'], ['fact 1 - ParamGrp2', 'qux', 'bom'], ['fact 1 - ParamGrp1', 'fuu', 'gong'], ['fact 2 - ParamGrp1', 'fiu', 'ging'], ); my %hash; my %param_hash; foreach my $nar (@nar) { my ( $cwd, $prm ) = split( " - ", $nar->[0] ); my @rest = @{$nar}[ 1 .. @{$nar} - 1 ]; push @{ $param_hash{$prm} }, [@rest]; $hash{$cwd} = {%param_hash}; } print Dumper \%hash ;
$VAR1 = { 'fact 1' => { 'ParamGrp2' => [ [ 'qux', 'bom' ] ], 'ParamGrp1' => [ [ 'foo', 'bar' ], [ 'fuu', 'gong' ] ] }, 'fact 2' => { 'ParamGrp1' => [ [ 'fiu', 'ging' ] ] } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Constructing HoHoA from AoA
by Limbic~Region (Chancellor) on Jan 02, 2006 at 05:16 UTC | |
by qbxk (Friar) on Jan 02, 2006 at 17:23 UTC | |
|
Re: Constructing HoHoA from AoA
by parv (Parson) on Jan 02, 2006 at 05:51 UTC | |
|
Re: Constructing HoHoA from AoA
by holli (Abbot) on Jan 02, 2006 at 10:57 UTC | |
|
Re: Constructing HoHoA from AoA
by Anonymous Monk on Jan 02, 2006 at 06:42 UTC | |
by Limbic~Region (Chancellor) on Jan 02, 2006 at 07:07 UTC | |
|
Re: Constructing HoHoA from AoA
by tphyahoo (Vicar) on Jan 02, 2006 at 15:36 UTC |