In short, this is a really good idea ... if done correctly. If done poorly, it will destroy your world in a bad way.
My first statement is to not use @EXPORT and instead use @EXPORT_OK. Then, do a use Shortcuts qw(debug);. That allows a reader of your code to know exactly where debug() is coming from. This is part-and-parcel of self-documenting code.
This is one of the bigger discussions in programming theory. I'm in the process of reading Code Complete (which I highly reccomend) and it discusses this very topic in great length throughout the book (of which I'm on chapter 8).
Basically, it all depends on a few factors:
- Are you documenting this? This is the biggest one.
- Are you using this in a large percentage of places?
- Are you using this as a repository of common functions? Are they documented?
- Do you have any globals? If you do, rip them out. Globals in a stand-alone script are arguably justifiable, if absolutely horrid style. If you start using globals across module lines, any reader of your code will rewrite it in disgust.
- Along the lines of #4, do NOT break the module's encapsulation. Ever. Not even once. Not even jokingly. If you're going through the trouble to create a module to store functionality, use all of its features and make it a black box. That way, if you want to change something across all your scripts (which is what this would allow you to do), you can do so and know that every script will still run, so long as you don't break the contract between the module and the scripts.
------
/me wants to be the brightest bulb in the chandelier!
Vote paco for President!
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.