No such thing as a small change | |
PerlMonks |
"use"ing from dynamic namespaceby dsheroh (Monsignor) |
on Dec 01, 2008 at 16:32 UTC ( [id://727140]=perlquestion: print w/replies, xml ) | Need Help?? |
dsheroh has asked for the wisdom of the Perl Monks concerning the following question:
I've been looking over my old code lately and finding a lot of projects where one has Foo::Module and another has an extremely similar Bar::Module, so I'm thinking the thing to do is factor out that commonality into Base::Module and derive both of the others from it.
Simple enough. However, Foo::Module references Foo::Config, Bar::Module references Bar::Config, and each needs to talk to different databases, if nothing else, so the referenced modules need to remain distinct for each app's namespace, but I've had no luck in trying to track down a conventional way of accomplishing this. What I've come up with so far is (in Base::Module): as a replacement for use xxx::Config qw(x y z) which should pull in Base::Config from Base::Module, Foo::Config from Foo::Module, and Bar::Config from Bar::Module, but it really feels horribly ugly and clumsy to me. Is this the standard way of accomplishing what I'm trying to do or is there a better solution out there?
Back to
Seekers of Perl Wisdom
|
|