I'm probably stating the obvious, but running code thru perltidy
often helps to clarify what is going on. Also I like
( the Tk front end to the perl debugger), it lets you step thru code, set break points, watch variables, and visually see how the code jumps. After some initial analysis, you can start separating code out into sections, then subs, etc.