The problem with deferring loading 'til runtime is that modules that make use of, say CHECK or INIT blocks will fail to work. Admittedly, such modules are usually 'language warping' type tools, but you might be attempting to use them indirectly.
A better option might be to have an Application class that loads everything the app needs in one fell swoop, which also helps with module codependencies. For the purposes of testing, where you want to make sure that modules you believe to be isolated actually are isolated, you could write yourself an export routine, so you could do:
use Application qw/Foo::Bar Foo::Baz Foo::Wibble/;
# Testcode goes here
For evilness points you could have Application detect when it's being run via testing code and have it add any 'new' modules to its list of modules to load when use
d without a module list. However, I think throwing an exception in all cases would be a rather more sensible option.
Going down that track a little further, if we assume that the only time Application will be used with a module list is during testing (if you want to vary the list of modules for different scripts, subclass Application) then you could have it generate a list of tested modules, then have a 99sanitycheck.t that verifies that Application has been used to explicitly load every module that it will load by default.
Hmm... I think I might have to find the tuits to write this.
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||