Here is my humble attempt to solve your interesting puzzle:
use strict; use warnings; use Data::Dumper; my %hash; my @row; while(<DATA>){ my ($level, $word) = /^(\s*)(\w*)$/; $level = length($level)/4; $row[$level] = $word; $#row = $level; my $last = \%hash; for (0..$#row) { $last->{$row[$_]} = $_ == $#row ? undef : {} if not defined $last- +>{$row[$_]}; $last = $last->{$row[$_]}; } } print Dumper \%hash; __DATA__ one two three four five six
In reply to Re: Parse data representing hash
by hdb
in thread Parse data representing hash
by peterp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |