K
kj
In perl documentation, I often run into references to a "DEBUG
constant", or some such. E.g., in the documentation for Carp::Assert
one sees code like this:
assert(EXPR) if DEBUG;
Is there in fact a special DEBUG constant in Perl, or does code
like the example above simply imply that elsewhere in the current
package one has a line like
use constant DEBUG => 0;
?
The above definition of DEBUG through the constant pragma is
straighforward enough but, as far as I can tell, it has the major
disadvantage of requiring the editing of the code to toggle its
value (as opposed to being easily settable from the command-line,
or perhaps from a config file), since all too often programmers
like me will forget to re-edit the code to ensure that DEBUG is
false in production code. Is this assessment correct?
Thanks!
kj
constant", or some such. E.g., in the documentation for Carp::Assert
one sees code like this:
assert(EXPR) if DEBUG;
Is there in fact a special DEBUG constant in Perl, or does code
like the example above simply imply that elsewhere in the current
package one has a line like
use constant DEBUG => 0;
?
The above definition of DEBUG through the constant pragma is
straighforward enough but, as far as I can tell, it has the major
disadvantage of requiring the editing of the code to toggle its
value (as opposed to being easily settable from the command-line,
or perhaps from a config file), since all too often programmers
like me will forget to re-edit the code to ensure that DEBUG is
false in production code. Is this assessment correct?
Thanks!
kj