Does anyone have or know of a tutorial on printing/looping through a nested hash with a variable number of nests? I know how to do it when the depth of the nesting is fixed and known, but when it's variable, I don't know of an efficient way to code it.
And I haven't figured out the correct keywords to find an example.
For a universal example of what I'm trying to do, lets look at an organization chart:
[tt]Director-1
Admin-1
Manager1-1
Supervisor-111
Worker-1111
Worker-1112
...
Supervisor-112
Worker-1121
...
Manager-12
Project Manager-121
Supervisor-121
Worker-1211
...
...
...
Director2
...[/tt]
If I was writing a report that would always pull the supervisors under a manager and the workers under them, I could use 2 nested foreach loops to output the data.
But what about when the manager has a project manager who doesn't have subordinates? Or what if I want to use that same report to pull everybody under a director or a VP and the nesting is 4 or 5 levels deep instead of 2? And they have administrative assistants who also don't have subordinates . . .
_________
Rott Paws
...It's not a bug. It's an undocumented feature!!!
And I haven't figured out the correct keywords to find an example.
For a universal example of what I'm trying to do, lets look at an organization chart:
[tt]Director-1
Admin-1
Manager1-1
Supervisor-111
Worker-1111
Worker-1112
...
Supervisor-112
Worker-1121
...
Manager-12
Project Manager-121
Supervisor-121
Worker-1211
...
...
...
Director2
...[/tt]
If I was writing a report that would always pull the supervisors under a manager and the workers under them, I could use 2 nested foreach loops to output the data.
But what about when the manager has a project manager who doesn't have subordinates? Or what if I want to use that same report to pull everybody under a director or a VP and the nesting is 4 or 5 levels deep instead of 2? And they have administrative assistants who also don't have subordinates . . .
_________
Rott Paws
...It's not a bug. It's an undocumented feature!!!