Putting every function in a separate file is not usually the way to go, since it tends to make maintenance harder, not easier. However, it is sometimes used to save memory and time by not compiling a bunch of code that doesn't usually get run. This is generally accomplished with the
AutoLoader module, which automates the job of splitting the subs out into files.
If you do decide to use a multi-file approach, I strongly recommend using "require" instead of "do" (for reasons already listed in this thread), and making the individual files separate packages with subs and nothing in their main:: space. This is a much cleaner way to do it, and avoids many problems with scoping and potential conflicts. Otherwise you'll have to keep track of which subs you have in each file and make sure you don't accidentally name two of the same, and ditto for global variables.
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.