... my $cfg; if (whatever) { $cfg = Foo::Config->new(...); } else { $cfg = Bar::Config->new(...); } my $obj = Base::Module->new( config => $cfg, ...); ...