in reply to Re^3: Convert delimited string into nested data structure
in thread Convert delimited string into nested data structure

No, I am afraid I spoke too soon. This does not work at all. Your code produces the following:
$VAR1 = [ { 'level' => 0, 'name' => 'root', 'children' => [ { 'level' => 1, 'name' => 'one', 'children' => [ { 'level' => 2, 'name' => 'bar' }, { 'level' => 2, 'name' => 'baz', 'children' => [ { 'level' => 3, 'name' => 'two' }, { 'level' => 3, 'name' => 'three' }, { 'level' => 3, 'name' => 'four' } ] } ] }, { 'level' => 1, 'name' => 'five' } ] }, $VAR1->[0]{'children'}[1] ];
'one' does not have any children.

Sorry, but this won't work for me either. Maybe this is a harder problem than I thought it would be.

Replies are listed 'Best First'.
Re^5: Convert delimited string into nested data structure
by philcrow (Priest) on Feb 19, 2007 at 19:26 UTC
    Ok, I'm sorry I posted code in haste. I wasn't ever trying to give you code you could use. I was only trying to explain the goal. See this article, which I mentioned in passing. I know the code in it works, and there is explanation.

    Phil