in reply to Namespace repair - better way to do it?
Concerning just
, you can haveuse lib 'modules';
andpackage Base::MainApp; use Base::FooBar; sub new { my ($class, $prototype) = @_; unless (ref $prototype eq 'HASH') { $prototype = {foobar=>Base::FooBar->new()}; } my $self = bless $prototype, $class; return $self; } sub method_using_foobar { my ($self) = @_; $$self{foobar}->foobarize(); } #rest of module
But it very depends how the current code is organized...package Client1::MainApp; use base 'Base::MainApp'; use Client1::FooBar; sub new { my ($class, $prototype) = @_; unless (ref $prototype eq 'HASH') { $prototype = {foobar=>Client1::FooBar->new()}; } my $self = Base::MainApp::new($class,$prototype); return $self; } #rest of module
|
|---|