in reply to Parse data representing hash
#!/usr/bin/perl use warnings; use strict; use Data::Diver qw{ DiveRef }; use Data::Dumper; my $hash = {}; my @path; while (<DATA>) { chomp; s/^(\t*)//; my $depth = length $1; splice @path, $depth + 1; $path[$depth] = $_; DiveRef($hash, @path); } print Dumper $hash; __DATA__ one two three four five six
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parse data representing hash
by peterp (Sexton) on Jun 28, 2014 at 22:28 UTC | |
|
Re^2: Parse data representing hash
by Anonymous Monk on Jun 28, 2014 at 22:30 UTC |