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 (Patriarch)
on Feb 23, 2013 at 19:46 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found