This is the raw data (pretty much).

level




journal




total




ref_num




stock lot buy_date sell_date shares cost proceeds gain_loss invaccount st_lt
3




IS









2350




Plum Creek 2 1998-01-07 2004-10-27 22.000000 531.67 758.54 226.87 DLJ Cash Acct LG
3




IS









2355




United Online 4 1999-09-23 2003-11-17 0.500000 26.67 10.00 -16.67 DLJ Cash Acct LL

This is the basic format I would like to create perhaps using Data::Tabular.

level


journal


total


ref_num


stock lot buy_date sell_date shares cost proceeds gain_loss invaccount st_lt
3


IS





2350


Plum Creek 2 1998-01-07 2004-10-27 22.000000 531.67 758.54 226.87 DLJ Cash Acct LG
2


IS








Plum Creek Total


22.000000 531.67 758.54 226.87

3


IS





2355


United Online 4 1999-09-23 2003-11-17 0.500000 26.67 10.00 -16.67 DLJ Cash Acct LL
2


IS








United Online Total


0.500000 26.67 10.00 -16.67

1


IS


Total





Total


22.500000 558.34 768.54 210.20


Then, I need to move to highly nested data such as this:

level

journal

ref_num

invaccount st_lt stock lot buy_date sell_date shares cost proceeds gain_loss
5

IS

2350

DLJ Cash Acct LG Plum Creek 2 1998-01-07 2004-10-27 22.000000 531.67 758.54 226.87
4

IS



DLJ Cash Acct LG Plum Creek Total


22.000000 531.67 758.54 226.87
3

IS



DLJ Cash Acct LG Total




531.67 758.54 226.87
5

IS

2355

DLJ Cash Acct LL United Online 4 1999-09-23 2003-11-17 0.500000 26.67 10.00 -16.67
4

IS



DLJ Cash Acct LL United Online Total


0.500000 26.67 10.00 -16.67
3

IS



DLJ Cash Acct LL Total




26.67 10.00 -16.67
2

IS



DLJ Cash Acct Total





558.34 768.54 210.20
1

IS



Total





558.34 768.54 210.20

Ultimately, I need to markup the data with class names based on the content.  That may take hacking Data::Tabular and adding a new layout type.  I need to have the Total lines be triggers to collapse the sections that they total.  So Collapsing the lowest level in the above table would look like this:

level

journal

ref_num

invaccount st_lt stock lot buy_date sell_date shares cost proceeds gain_loss
3

IS



DLJ Cash Acct LG Total




531.67 758.54 226.87
3

IS



DLJ Cash Acct LL Total




26.67 10.00 -16.67
2

IS



DLJ Cash Acct Total





558.34 768.54 210.20
1

IS



Total





558.34 768.54 210.20

There is a ton of work to do to get everything to this level and there's more.  I'd like the Green Totals in the above table to disappear.  I need to have the ability to expand/collapse one section at a time or all sections on the same level at the same time.  I have prototypes of all of this collapsing stuff in action.  My problem is getting the data from the database or 2d array structures transformed into some sort of format that I can add collapsing to.   It doesn't have to be the same format as in the prototypes.