use B;
sub LogMe{
#calling other subroutines and do a lot of stuff
print "logme is called\n";
B->new;
B->_func2;
};
####
package commonRoutine;
sub new
{
my ($class, $cacheFileName) = @_;
my $this = bless({}, ref($class) || $class);
# Initialize member variables.
$this->{initialized} = 1;
$this->{lastFlushTime} = time();
return $this;
}
##
# Destructor. Clean up object.
#
sub DESTROY
{
my $this = shift;
$this->_func2();
}
sub _func3{
print "me\n";
}
1
####
use A;
use commonRoutine;
do ('LogMe.pl');
sub enter{
A->new;
commonRoutine->new;
}
####
package A;
use strict;
use B;
use commonRoutine;
do ('LogMe.pl');
##
# Constructor. Initialize instance of object.
#
# @param $cacheFileName [in] Name of cache file.
#
# @return Instance of object or undef if failure.
#
sub new
{
print "A->new()\n";
my ($class, $cacheFileName) = @_;
my $this = bless({}, ref($class) || $class);
# Initialize member variables.
$this->{initialized} = 1;
$this->{lastFlushTime} = time();
$this->_func1();
return $this;
}
##
# Destructor. Clean up object.
#
sub DESTROY
{
my $this = shift;
}
sub _func1{
LogMe();
print "me\n";
}
1
####
package B
sub new
{
my ($class, $cacheFileName) = @_;
my $this = bless({}, ref($class) || $class);
# Initialize member variables.
$this->{initialized} = 1;
$this->{lastFlushTime} = time();
$this->_func2();
return $this;
}
##
# Destructor. Clean up object.
#
sub DESTROY
{
my $this = shift;
$this->_func2();
}
sub _func2{
print "me\n";
}
1