Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: any way to fill calling namespace with a "use Module"?

by Corion (Pope)
on Feb 23, 2013 at 19:46 UTC ( #1020337=note: print w/replies, xml ) Need Help??

in reply to any way to fill calling namespace with a "use Module"?

I would restructure the object hierarchy as follows:

package Top::Base; use Moose; 1; package SubordinateA; use Moose; extends 'Top::Base'; 1; package SubordinateB; use Moose; extends 'Top::Base'; 1;

... and then introduce a new "Top" class that doesn't inherit from Moose and whose ->new method is just a factory for the others:

package Top; sub new { my ($class, %options) = @_; my $impl= "Top::$options{ base }"; $impl->new( %options ); };

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020337]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-06-24 01:07 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (555 votes). Check out past polls.