in reply to Re: Re: Flat hash to structured
in thread Flat hash to structured

I'll give it a shot:

Top item has an id number and a Children array. Each item in Children in turn has a Childeren array, and so on and so forth. Each item down the chain also has a Parents array, but instead of complex data, all the Parents array has is the id numbers, in reverse order, of the items above it (all the way to item 1). So ALL item's Parents array will have number 1 as it's last element in the array.

Again, the Children's array actually holds the children, and so on and so forth ad infinitum.

The end result is that I will be walking back down the chain, printing item names, etc. and total accumulated work hours for each item (which is in each item). Children of items are moved over 4 spaces, and so on. The "total hours" of each item is the total of it's children's hours plus any work hours done directly on the parent.
So my end printout will look like:

Main 450 Project 1 300 Sub 1 150 Sub 2 150 Project 2 150 Sub 1 75 Sub 2 75

As you can see, it is cummulative. And, because subs and projects can be "moved" within the main system, I cannot count on numerical order of their id numbers - I must rely on the Parent and Children arrays.

My employer already has a module which will print this out correctly for me, but it requires a single complex hash as it's input, structured as mentioned above. And no, I cannot use anything else to print it - his module gives correct formatting, bg colors, etc. etc. so he insists I use it.

Does this help?

What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"