On Friday 06 August 2010 11:51:02 Octavian Rasnita wrote:
> Hi,
>
> I have a question regarding a set of modules that subclass each other, and
> I hope it is appropriate for this group.
>
> Here is a test program (with no use strict and warnings for beeing
> concise):
>
> # program.pl:
>
> #!/usr/bin/perl
> use Third;
> Third->new->run;
>
> # Third.pm:
>
> package Third;
>
> use parent 'Second';
>
> sub run {print "Third\n";}
>
> 1;
>
> # Second.pm:
>
> package Second;
>
> use parent 'First';
>
> sub new {
> my $class = shift;
> my $self = $class->SUPER::new;
> #bless $self;
You shouldn't call bless here again. It will override the bless $self, $class
in the constructor which is Third in a case. Call bless once for every
reference, unless you want the rare case of changing the object's class in
run-time.
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
What does "Zionism" mean? - http://shlom.in/def-zionism
God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/