ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
You can think of this data structure as a tree:{ "tool": "A", "version": "1.3", "dependencies": [ { "tool": "B", "version": "8.23", "dependencies": [] }, { "tool": "C", "version": "2.1", "dependencies": [ { "tool": "D", "version": "1.1", "dependencies": [] } ] } ] }
I want to do a postorder traversal on this tree and to be able to print the tool/version. So I get:A / \ B C | D
The problem is that I'm not sure how to to do it. I need to find each leaf and then remove it (???) in order to mark that "I was here". I'm sure that there is a better way to handle it and this is why I'm asking here. Is it possible to suggest a better way?B/8.23 D/1.1 C/2.1 A/1.3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Postorder on hash structure
by Corion (Patriarch) on Aug 08, 2021 at 16:16 UTC | |
|
Re: Postorder on hash structure
by tybalt89 (Monsignor) on Aug 08, 2021 at 17:07 UTC | |
|
Re: Postorder on hash structure
by karlgoethebier (Abbot) on Aug 08, 2021 at 15:43 UTC |