in reply to Re^2: defining constant in other package
in thread defining constant in other package
Perl wants a constant (subroutine) to have an empty prototype before it eliminates code guarded by it:
BEGIN { sub MyPackg::DBG() { 0; } } our $a = 1; package MyPackg; print 'DEBUGGING' if DBG(); # <-- oops print 'huhu';
gives this output:
F:\>perl -MO=Deparse tmp.pl sub MyPackg::DBG () { 0 } sub BEGIN { } our $a = 1; package MyPackg; '???'; print 'huhu'; tmp.pl syntax OK
In Section
Seekers of Perl Wisdom