dsheroh has asked for the wisdom of the Perl Monks concerning the following question:
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.BEGIN { my $ns = __PACKAGE__; $ns =~ s/::[^:]*$//; eval "require $ns\::Config"; "$ns\::Config"->import(qw(x y z)); }
Is this the standard way of accomplishing what I'm trying to do or is there a better solution out there?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "use"ing from dynamic namespace
by perrin (Chancellor) on Dec 01, 2008 at 17:39 UTC | |
by dsheroh (Monsignor) on Dec 01, 2008 at 18:14 UTC | |
by pobocks (Chaplain) on Dec 02, 2008 at 10:54 UTC | |
by almut (Canon) on Dec 02, 2008 at 13:47 UTC | |
by pobocks (Chaplain) on Dec 02, 2008 at 23:37 UTC | |
by almut (Canon) on Dec 03, 2008 at 01:15 UTC | |
|
Re: "use"ing from dynamic namespace
by samtregar (Abbot) on Dec 01, 2008 at 17:43 UTC | |
by dsheroh (Monsignor) on Dec 01, 2008 at 18:42 UTC | |
|
Re: "use"ing from dynamic namespace
by almut (Canon) on Dec 01, 2008 at 19:23 UTC | |
|
Re: "use"ing from dynamic namespace
by ikegami (Patriarch) on Dec 01, 2008 at 18:49 UTC | |
|
Re: "use"ing from dynamic namespace
by ikegami (Patriarch) on Dec 01, 2008 at 18:52 UTC |