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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2016-06-30 04:55 GMT
Find Nodes?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...

    Results (389 votes). Check out past polls.