#!perl
use
lib
qw( t t/lib ./lib ../lib )
;
{
BEGIN {
our
@EXPORT_INHERIT
=
qw( $staticData1 $staticData2 $staticData3 )
;
}
our
$staticData1
= 1;
our
$staticData2
= 2;
our
$staticData3
= 3;
sub
new {
my
$class
=
ref
$_
[0] ||
$_
[0];
bless
{
instanceData1
=> 1,
},
$class
;
}
sub
staticMethodA {
print
"- staticMethodA\n"
;
}
sub
staticMethodB {
print
"- Base staticMethodB $staticData1\n"
;
}
sub
staticDump {
print
"Base.staticDump()\n"
,
"\tstaticData1: $staticData1\n"
,
"\tstaticData2: $staticData2\n"
,
"\tstaticData3: $staticData3\n"
;
}
sub
instanceDump {
my
$self
=
shift
;
print
"Base.instanceDump() "
,
ref
$self
,
"\n"
,
"\tstaticData1: $staticData1\n"
,
"\tinstanceData1: $self->{instanceData1}\n"
;
}
}
{
BEGIN {
our
@EXPORT_INHERIT
=
qw( $staticData1 )
;
inherit Base;
};
our
$staticData1
=
"111"
;
$staticData3
=
"333"
;
sub
new {
my
$class
=
ref
$_
[0] ||
$_
[0];
bless
{
%{
$class
->SUPER::new(
@_
) },
instanceData2
=>
"222"
,
},
$class
;
}
sub
staticMethodB {
print
"- Derived staticMethodB $staticData1\n"
;
}
sub
staticDumpB {
print
"Derived.staticDumpB()\n"
,
"\tstaticData1: $staticData1\n"
,
"\tstaticData2: $staticData2\n"
,
"\tstaticData3: $staticData3\n"
;
}
sub
instanceDumpB {
my
$self
=
shift
;
print
"Derived.instanceDumpB() "
,
ref
(
$self
),
"\n"
,
"\tstaticData1: $staticData1\n"
;
}
}
my
$base
= Base->new();
my
$derived
= Derived->new();
$base
->staticMethodA();
$derived
->staticMethodA();
$base
->staticMethodB();
$derived
->staticMethodB();
$base
->staticDump();
$base
->instanceDump();
$derived
->staticDump();
print
"\n"
;
$derived
->instanceDump();
$derived
->staticDumpB();
$derived
->instanceDumpB();