Alternate solution for reference:
package PClass1;
use strict;
use Carp;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my (%args) = @_;
my $this = {
_fs => $args{fs} || croak("You must supply a filesystem"),
};
bless $this, $class;
return $this;
}
...
package PClass2;
use strict;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my (%args) = @_;
my $this = {
_hosts => $args{hosts},
};
bless $this, $class;
return $this;
}
......
package Subclass;
use strict;
use PClass1;
use PClass2;
our @ISA=qw(PClass1 PClass2);
sub new {
my ($class, %args) = @_;
#################### Start of changes ####################
my $obj1 = $class->PClass1::new(%args);
my $obj2 = $class->PClass2::new(%args);
$this = $class->PClass1::new(%args);
my $this = {( %{$obj1}, %{$obj2} )};
bless $this, $class;
#################### End of changes ####################
return $this;
}