E
ed
Is there anything wrong with calling the parent's constructor
this way?
It all seems to work as expected. For instance if I take the
"printVars()" sub out of test3 the one in test2 executes.
# -- start perl code
{ package test1;
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $this = {};
bless($this, $class);
print "in test1::new \n";
$this->{test1} = 'this is test1';
return $this;
}
}
{ package test2;
use base qw(test1);
sub new
{
$this = test1::new(@_);
print "in test2::new \n";
$this->{test2} = 'this is test2';
return $this;
}
sub printVars
{ my $this = shift;
print "in test2:rintVars \n";
}
}
{ package test3;
use base qw(test2);
sub new
{
$this = test2::new(@_);
print "in test3::new\n";
$this->{test3} = 'this is test3';
return $this;
}
sub printVars
{ my $this = shift;
print "\$this->{test1} = $this->{test1} \n";
print "\$this->{test2} = $this->{test2} \n";
print "\$this->{test3} = $this->{test3} \n";
}
}
$obj = test3->new();
$obj->printVars();
#-- end perl code
tia,
--ed
this way?
It all seems to work as expected. For instance if I take the
"printVars()" sub out of test3 the one in test2 executes.
# -- start perl code
{ package test1;
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $this = {};
bless($this, $class);
print "in test1::new \n";
$this->{test1} = 'this is test1';
return $this;
}
}
{ package test2;
use base qw(test1);
sub new
{
$this = test1::new(@_);
print "in test2::new \n";
$this->{test2} = 'this is test2';
return $this;
}
sub printVars
{ my $this = shift;
print "in test2:rintVars \n";
}
}
{ package test3;
use base qw(test2);
sub new
{
$this = test2::new(@_);
print "in test3::new\n";
$this->{test3} = 'this is test3';
return $this;
}
sub printVars
{ my $this = shift;
print "\$this->{test1} = $this->{test1} \n";
print "\$this->{test2} = $this->{test2} \n";
print "\$this->{test3} = $this->{test3} \n";
}
}
$obj = test3->new();
$obj->printVars();
#-- end perl code
tia,
--ed