in reply to Generating a list of lists (for HTML::Element) from trivial markup
You're always pushing new elements on the same array in different positions, not different depths:
push @{$list[$depth]}, @current_list;
For instance, in order to h2 being a child of greybox you should:
push @{$list[0][3]}, @current_list;
Where depth means there's 2 array references involved. That's why the recursive solution provied by jethro works better: recursion and depth are intimate concepts.
|
|---|