in reply to Conditional inheritance strategy

Don't have My inherit from My::XML and My::JSON, have My::XML and My::JSON inherit from My.

I'm guessing you want to do this since you get a file name and you want to load the file using the right module.

package My; sub load { my ($class, %args) = @_; my $file_type = ...; if ($file_type eq 'xml') { require My::XML; return My::XML->new(%args); } elsif ($file_type eq 'json') { require My::JSON; return My::JSON->new(%args); } } sub new { ... } sub method1 { ... } sub method2 { ... }