Personally, I find that the most helpful thing when I am maintaining a "complex script" is to have a block of comments detailing the program input structure(s) and the expected output structure. Once you know where you start and where you want to go, the path becomes luminously clear. There is a line from Fred Brooks's (
The Mythical Man Month) to the effect that flow charts are pretty pictures, but to understand what the code does, show me the tables. (My copy of MMM is in storage at the moment, so I am paraphrasing from leaky memory.)
----
I Go Back to Sleep, Now.
OGB