Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: defining constant in other package

by Corion (Pope)
on Apr 24, 2012 at 14:45 UTC ( #966861=note: print w/ replies, xml ) Need Help??


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


Comment on Re^3: defining constant in other package
Select or Download Code
Re^4: defining constant in other package
by LanX (Canon) on Apr 24, 2012 at 14:50 UTC
    Argh , thanks, already forgot about this.

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://966861]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-08-20 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (124 votes), past polls