Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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 ); };


Comment on Re: any way to fill calling namespace with a "use Module"?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-08-28 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls