, , .
package BaseClass;
sub new {
my $a = caller(0);
for (my $n=0; my @c=caller($n); $n++) {
last if $c[4] !~ /::new$/;
$a = $c[0];
}
print $a;
}
package BaseClass;
sub new {
my @a;
unshift @a, [ caller(@a) ] while caller(@a);
my ($a) = grep { $_->[4] =~ /::new$/ } @a;
print $a // caller(0);
}
, , , ,
GrandChild::new
GrandChild::init
Inherited::new
BaseClass::new
Inherited::new ( GrandChild, GrandChild::new.