I'm trying to organize a flat file into an org-chart type hierarchy.
The flat file contains many rows that each contain an employee name and their direct manager's name.
So far I've successfully read through the file line by line and loaded the hash of arrays with the following line:
push(@{$hash{$manager}}, $employee);Now I want to start with the top employee (CEO) and print a hierarchical output like this, all the way to the lowest level:
CEO
VP1
DIRECTOR1
DIRECTOR2
EMPLOYEE1
VP2
DIRECTOR3
DIRECTOR4
EMPLOYEE2
I can print the first level, of course, but I'm not sure how to go about extending this to walk through the whole structure:
for $i ( 0 .. $#{ $hash{"CEO"} } ) { print $hash{"CEO"}[$i] . "\n"; }
Would appreciate some guidance, thanks!
In reply to Recursive walk through hash of arrays by paulzakas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |