My first significant Perl script was a CGI database manager. Because it was my first script, I did a lot of things that, in the light of more experience, seem dead wrong. One of those things was combining too many functions (i.e. query handlers) into one large program. It started innocently enough. I just wanted to be able to make a query, do a search, and present the results. Then came the stats. Heck, I can compute the stats in the same program. After all, the data access engine is already there. After that came an addition to format the stats in a nice downloadable pdf. Might as well just stick that in there, too! And did I mention how convenient having all that stuff in one big script made it to use global variables? Well, you get the idea.
As far as compile-time goes, frankly I don't care whether it's 10 milliseconds or two seconds. It's not one of those 10,000 hits-per-day sites. What I do care about is maintainability, and the capacity to modify function by building out rather than up. This could have been achieved by having one module whose only job was to interface to the database via exported data objects and methods. That way each query could have been handled by a different, much shorter script, and the data retrieved and contained in nice, tidy object variables instead of being splattered across a score or two of global scalars. Plus -- and most importantly of all -- I could follow the logic of each query handler without having to scroll back and forth through several thousand lines of code.
Now I know. And I'm sorely tempted to do a major rewrite, except -- doggone it all -- the blasted thing works!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.