my @stack = ({}); while (<DATA>) { s/\s+$//; # remove trailing space and newline my $depth = 0; $depth++ while $depth < @stack && s/^[|` ][- ] //; die 'malformed input' if $depth < 1; splice @stack, $depth; my $obj = $stack[-1]; if (/^(.*?) = ?(.*)/) { $obj->{$1} = $2 eq 'undef' ? undef : $2; } elsif (s/ \(no elements\)$//) { $obj->{$_} = []; } else { push @stack, $obj->{$_} = {}; } } my $output_hash = $stack[0];
In reply to Re^3: TreeDumper Parser / Inverse?
by Anonymous Monk
in thread TreeDumper Parser / Inverse?
by jimpudar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |