#!/usr/bin/perl -wT ############################################################################ package P1; sub new() { warn __PACKAGE__; my $this = shift(@_); # Invocand package name. my $class = ref($this) || $this; my $self = {}; bless($self, $class); $self->initialize({@_}); return($self); } sub initialize($) { my $self = shift(@_); $self->{counter}++; }; ############################################################################ package P2; our @ISA = ('P1'); sub new() { warn __PACKAGE__; my $this = shift(@_); # Invocand package name. my $class = ref($this) || $this; my $self = {}; bless($self, $class); $self->SUPER::initialize({@_}); $self->initialize({@_}); return($self); } sub initialize($) { my $self = shift(@_); $self->{counter}++; }; ############################################################################ package P3; our @ISA = ('P2'); sub new() { warn __PACKAGE__; my $this = shift(@_); # Invocand package name. my $class = ref($this) || $this; my $self = {}; bless($self, $class); $self->SUPER::initialize({@_}); $self->initialize({@_}); return($self); } sub initialize($) { my $self = shift(@_); $self->{counter}++; }; ############################################################################ package main; printf "Depth: %d of 3\n", P3->new()->{counter}; ############################################################################ 1; # Don't forget to return a true value from the file.