note
haj
<p>I don't think I understand how you want to insert a fourth package "sometimes, but not always" in the hierarchy of package Three. Is this for different programs using the same package Three, for different runs of the same program, for different modules in one program which use package Three - or for different objects within the same program? Does the decision happen when you write your code, or at compile time, or at run time?</p>
<p>If the decision happens at runtime on a per-object base: I once had such a problem and found [mod://Moose] with its roles to be a suitable approach (because the program used introspection anyway). Thanks to its meta protocol, Moose allows to add roles (which would be your intermediate packages) to existing objects, so objects can "learn new tricks during runtime".</p>
<p>If the decision happens once for a program run, I'd go for a plugin mechanism as suggested by Corion in [id://11105507].</p>
11105504
11105504