in reply to Re: read flat file and build tree-like structure
in thread read flat file and build tree-like structure
Close. Keep track of a reference to the reference.
my %hash; while (<>) { chomp; my ($key, $val) = split(/=/, $_, 2); my @elts = split(/\./, $key); my $p = \\%hash; $p = \( ${$p}->{$_} ) for @elts; $$p = $val; } use Data::Dumper; print Dumper(\%hash);
Tested.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: read flat file and build tree-like structure
by manav_gupta (Acolyte) on Nov 19, 2007 at 17:17 UTC | |
by manav_gupta (Acolyte) on Nov 19, 2007 at 17:22 UTC | |
by ikegami (Patriarch) on Nov 19, 2007 at 19:07 UTC |