in reply to Re: defining constant in other package
in thread defining constant in other package
> perl -MO=Deparse tst.pl sub BEGIN { sub MyPackg::DBG { 0; } } our $a = 1; package MyPackg; print 'DEBUGGING' if DBG(); # <-- oops print 'huhu'; tst.pl syntax OK
OK forget it this works, thanks!
BEGIN { sub MyPackg::Debug {!!0}; } our $a=1; package MyPackg; use constant DBG => MyPackg::Debug; print "DEBUGGING" if DBG; # won't be compiled print "huhu";
> perl -MO=Deparse tst.pl sub BEGIN { sub MyPackg::Debug { 0; } } our $a = 1; package MyPackg; sub BEGIN { require constant; do { 'constant'->import('DBG', Debug()) }; } '???'; print 'huhu'; tst.pl syntax OK
Cheers Rolf
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: defining constant in other package
by Corion (Patriarch) on Apr 24, 2012 at 14:45 UTC | |
by LanX (Saint) on Apr 24, 2012 at 14:50 UTC |
In Section
Seekers of Perl Wisdom