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.
In reply to Re^2: read flat file and build tree-like structure
by ikegami
in thread read flat file and build tree-like structure
by manav_gupta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |