LanX has asked for the wisdom of the Perl Monks concerning the following question:
Hi
UPDATE:
at least it can be simplified for the user with lexically scoped packages:
For a package which I'm coding I wanna offer to switch on debugging by a constant!
The idea is that the related code is not compiled if the flag is false (codefolding)¹ thus not causing performance lost if in non-debug mode.
Is there any way to tell use constant which namespace to use?
ATM I'm using something like
Any nicer way to achieve this?# --- user's code package MyPackg; use constant DBG => 0; package main; ... MyPackg::func(); ... # --- my code package MyPackg; sub func { print "DEBUGGING" if DBG; # won't be compiled }
Cheers Rolf
UPDATE: ¹) better phrased as "unreachable code removal"{ package MyPackg; use constant DBG => 0; }
|
---|
Back to
Seekers of Perl Wisdom