in reply to Lots of subs in large program vs lots of small programs

The script currently works fine, but is about 1000 lines (I know this is short for some of you system admin folks), and besides using the aforementioned good coding practices, I'd like to trim down the code by about 2/3rds.
First of all, rewriting something you are familiar with from the ground up with best practices in mind is an excellent choice. But, I will caution you that making it smaller isn't really a good design goal. Simpler, yes. Smaller will very likely be a pleasant side effect of better design.

Go with modularization. I am sure you'll get many suggestions (good ones too) about this, so I'll offer up what I feel might be a good way for you to think about it, rather than specific suggestions of what to put where.

You've coded it all up once already, and you've used a couple of modules. Review your main code with the following in mind: If you could simply wish any module into existence (within reason and logic), can you imagine any that would simplify your design? "Gee, if the Such::and::Such module existed, I'd only have to do this and this, which is really the core of my application, and not all this other stuff".

Take your time, and consider the kinds of work you are already *not* doing because HTML::Template or DBI already existed. What other kind of work would it be nice to *not* be doing in your mainline code? Jot down all the ideas that arise, even contradictory ones. Further thought, or perhaps questions and musings here, can help you choose among and refine these core ideas. These are your potential module candidates.

As for recommendations for subs at top or bottom, the thread you referenced contains most of the available arguments, no reason to rehash it again.

  • Comment on Re: Lots of subs in large program vs lots of small programs