in reply to use warnings and debug messages
Hello szabgab,
I actually like your own proposed solutions. But here is another possibility:
use 5.010; use strict; use warnings; use constant DEBUG => 1; no if DEBUG, warnings => 'uninitialized'; my $x = 23; my $y; say "With DEBUG = ", DEBUG; debug("x='$x' y='$y'") if DEBUG; if (DEBUG) { sub debug { say shift; } }
Output:
22:41 >perl 1758_SoPW.pl With DEBUG = 0 22:41 >perl 1758_SoPW.pl With DEBUG = 1 x='23' y='' 22:41 >
The downside, of course, is that you have to add if DEBUG to the end of all your existing debug calls. :-(
Anyway, hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|