The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Reading between the lines, common.pm doesn't have a package statement at the top? Perl will only require a file once. So if you do things the way you're doing them, the functions defined in common.pm will end up only in the first package that loads the file. What you want to do is make common.pm into a package in its own right, which uses Exporter or Sub::Exporter or similar to copy its functions into every package that imports it. Sample common.pm...
Then your other modules can just:
And they automatically get do_this and do_that functions.
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In reply to Re: Single module spanning multiple Packages,
by tobyink
|
|