http://qs321.pair.com?node_id=1048883


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