in reply to Complex Hashing
You'll want references to hashes, and a loop.
use strict; use warnings; use Data::Dumper; my $hashref = {}; my $hashrefTemp = $hashref; $hashrefTemp = ($hashrefTemp->{a} ||= {}); $hashrefTemp = ($hashrefTemp->{b} ||= {}); $hashrefTemp->{e} = 'd'; print Dumper $hashref;
$VAR1 = { 'a' => { 'b' => { 'e' => 'd' } } };
Looping and I/O is left as an exercise for the reader.
Dealing with input where an endpoint coexists with a non-endpoint is also left as an exercise for the reader. (Eg: [['a','b'] ['a','b','c']])
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Complex Hashing
by joshpk105 (Initiate) on Oct 28, 2011 at 19:29 UTC | |
|
Re^2: Complex Hashing
by joshpk105 (Initiate) on Oct 28, 2011 at 18:10 UTC |