The way you have the code I think the easiest solution would be to change the meaning of the LVLx constants from "the ID of the level" (where most likely LVL1 == 1, LVL2 == 2, etc.) to "is the debug for this level turned on?". So that you could change your debug statements to

debug "this..." if LVL1; ... debug "that .." if LVL3;
You'd have to change the debug() subroutine to just
sub debug { print "$_\n" for @_; }
and make sure the LVLx constants are defined in time ... either by enclosing the debug level setting and constant definition in a BEGIN{} block or by doing that in a module you use on top of the program. Something like
BEGIN { ... read the levels that should be ON to %debug for (1.. $count_of_levels) { eval "sub LVL$_ () {$debug{$_}};"; } }


In reply to Re: removing debugging code at compile time ? by Jenda
in thread removing debugging code at compile time ? by rootcho

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.