I am new to Perl inheritance and haven't been able to find explicit instructions for inheriting the parent constructor. I assumed that all methods (including the constructor) from the parent class are inherited but it appears that this isn't the case. So, this is not enough:
package Child;
use strict;
use Parent;
our @ISA=qw(Parent);
Instead, I need to add a constructor that calls the parent constructor:
package Child;
use strict;
use Parent;
our @ISA=qw(Parent);
sub new {
my $self=Parent::new(shift);
bless $self;
return $self;
}
Perhaps somebody can clarify the logic for me and tell me if the parent constructor be inherited without doing what I did above (explicit declaration and calling the parent constructor)?