in reply to inlined DEBUG constant versus $DEBUG

C's method is to use preprocessing, which I've heard is coming out (in some form) in Perl6. Thus, if DEBUG is set to 0, the compiler would just skip over that code and not even compile it to optimize it away.

As a note, just do

use constant DEBUG => (1);
if you're in 5.6.0 or higher. (It may be available earlier, but I'm not sure.)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re:x2 inlined DEBUG constant versus $DEBUG
by grinder (Bishop) on Sep 18, 2001 at 21:26 UTC

    If you are wondering whether use constant is available in versions prior to 5.6.0, it was introduced in 5.004. In fact if you were using the late 5.003 versions (circa 5.003_90+) it was there in betas leading up to 5.004.

    Nevertheless, it's been there for a long time, at least as far as scalars go. Constant hashes and arrays didn't work correctly until around 5.005_03.

    --
    g r i n d e r
Re: Re: inlned DEBUG constant versus $DEBUG
by perrin (Chancellor) on Sep 18, 2001 at 21:41 UTC
    You can use a pre-processor with Perl too. See Filter::cpp.