# parent class
package parent
sub new{
my $type= shift;
my $class=ref($type)||$type;
my $self = {data1=>undef, data2=>undef};
bless $self, $class;
return self;
}
;
#child class
package class
use parent
our @ISA=("parent"); # this is extend, if method can't find in self class, then find in @ISA classes, if still not, find in AUTOLOAD, but you must call use AUTOLOAD first; if failed, then try in UNIVERSAL class, all attenption failed, throw exception
sub new{
my $type= shift;
my $class=ref($type)||$type;
my $self = $class->super::new; #继承父类数据
$self->{data3}="";#创建自己数据
bless $self, $class;
return self;
}