Well, one easy and straightforward way to do this is to use lib qw( devel/lib/path ); in your development copy, and delete that line in production copies.

Another way would be to unshift into @INC (see perlvar) in a BEGIN block. The following code puts './lib' at the head of the line for module searches if $devel is true, and does nothing if it is false. This lets you tie other things to the same variable if needed, so you only change it in one place.

BEGIN { my $devel = 0; if ( $devel ) { unshift @INC, qw( ./lib ); } }

You could also conditionally require a module and then call its import method/sub. This can be done outside a BEGIN block, since require() happens later than does use().

Finally, there are advanced options that have to do with playing tricks with @INC (like putting coderefs in it and such), but those are probably best left alone until you have a solid grasp of other ways to conditionally require a module.


In reply to Re: Separating Development and Release Modules by mr_mischief
in thread Separating Development and Release Modules by Irinotecan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.