in reply to Parse data representing hash
Your HoHoH... has always hashrefs or undef as values.
You need one state var: an @path array holding the refs till the last value so far.
Whenever you parse the indentation you get the index of the next entry in @path and "parent" entry points to the hash you need to extend.
if smaller you need to shorten @path, if bigger you have to extend @path and transform the last undef into a hashref.
I hope you get the idea...
I'm mobile so no chance for tested code, but I'm sure the archive has many examples.
Cheers Rolf
(addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parse data representing hash
by peterp (Sexton) on Jun 28, 2014 at 22:21 UTC | |
by LanX (Saint) on Jun 28, 2014 at 22:45 UTC | |
by peterp (Sexton) on Jun 28, 2014 at 23:21 UTC |