Really? If you leave the 'use ifdef' in your code, it will only marginally affect your load time, won't really affect your compile time (just the part of ignoring POD), and won't affect runtime at all.

Or, another way to look at it is that commenting out the "use ifdef" line is way easier than commenting out all the DEBUGGING lines. :-)

One minor advantage here is that you can control which files have ifdef in them - by only putting them in the files you actually want to debug at a given time, you can just get your debugging info from those modules - a significantly reduced set of messages which may make it easier to debug. Minor, but still an advantage.

What's really unfortunate is that the lib module doesn't play too nice here. We could, however, write a new module, say lib::clean, which would go and reorder the @INC such that all CODE refs are pushed to the front. Then you just need to use it:

package lib::clean; sub import { my (@coderefs, @rest); foreach (@INC) { if (ref $_ && ref $_ eq 'CODE') { push @coderefs, $_; } else { push @rest, $_; } } @INC = (@coderefs, @rest); } 1;

And just 'use lib::clean;' after the 'use lib' line. Just testing that, and it seems to work, too.


In reply to Re^7: ifdef in modules by Tanktalus
in thread ifdef in modules by Anonymous Monk

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.