in reply to Conditionally executing debugging code
Ah, but if you simply do something like:
then, when debugging is not turned on, the conditional debug code is actually eliminated by the Perl optimizer so that it doesn't take up memory and the "if" conditional never even gets run!BEGIN { eval "sub DEBUG() {" . ( $ENV{DEBUG} ? "1" : "0" ) . "}"; } # ... if( DEBUG ) { code here; } warn "Stuff" if DEBUG;
Update: Yes, bbfu's idea is even better. (:
- tye (but my friends call me "Tye")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(bbfu) Re: (tye)Re: Conditionally executing debugging code
by bbfu (Curate) on May 26, 2001 at 07:01 UTC |