in reply to C pre-processor

Perl does some internal optimization. (Various meanings can be assigned to 'some', most of which are correct.)

In particular, it can remove execution paths which will never be reached:

chromatic$ perl -MO=Deparse print "hi"; if (0) { print "hi" } - syntax OK print 'hi!'; '???';
If you use a constant for DEBUG and set it to 0, I'm 99.8% convinced Perl will do the right thing and not even compile the debugging code.

Update: I just ran a test with a real Perl package, and it works. You might want to put your constant declaration in a BEGIN{} block, just to be on the safe side.

Replies are listed 'Best First'.
Re (tilly) 2: C pre-processor
by tilly (Archbishop) on May 01, 2001 at 23:31 UTC
    Note. Perl's definition of "never be reached" is unaware of the possibility of being reached by goto. This is documented, so the following proves your assertion and is not a bug in Perl:
    if (0) { FOO: { print "How many times will I print?\n"; } } goto FOO;
    Note, however, that Perl will parse the code in the commented out section. If this bothers you, you can do arbitrary pre-processing through Filter::Simple. (Note that the inability to parse arbitrary Perl makes this facility substantially less useful than it could be...)