Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Accessing DEBUG constant from sub-package

by tobyink (Canon)
on Aug 10, 2013 at 07:06 UTC ( [id://1048883]=note: print w/replies, xml ) Need Help??


in reply to Accessing DEBUG constant from sub-package

Personally I'd do something like this in the Thing package:

use constant DEBUG => main->can("DEBUG") && main->DEBUG;

This makes your Thing package more re-usable, allowing it to be used in scripts that don't define a DEBUG constant in the main package.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found