Thank you for everybody.

Now I can clear the things a little bit.

I originally had a sub new, which I didn't mention before.  I 
actually couldn't find them when I browsed my script.  What a shame.

It was like this,

sub new {
    my $this = shift;
    my $class = ref($this) || $this;
    my $self = {};
    bless $self, $class;
    $self->initialize();
    return $self;
}

So, Michael's first advise was already implemented in my script, but 
it was not working.  Sorry for confusing.

And then I've changed it to,

sub new
{
    my( $self ) = shift;
    $self->SUPER::new(@_);
}

I reported it didn't work, but now it does.  The reason why it didn't 
work seems to depend on my macintosh environment.  It works on one 
machine, but not on other. I have to check this.

Finally, I have,

sub new
{
    my $class = shift;
    my $self = $class->SUPER::new(@_);
    $self->initialize( @_ );
    $self;
}

as Randal advised. And this works!  Thanks.

Now I also put,

    $self->SUPER::init();

in my initializing routine. Do you think it necessary?


Randal L. Schwartz wrote on 00.4.17 4:10 AM: 
>>>>>> "Michael" == Michael A Chase <[EMAIL PROTECTED]> writes:
>
>Michael> He's trying to subclass HTML::Parser, so creating an HTML::
Parser object is
>Michael> not what he's wants to do, just add HTML::Parser 
capabilities to his own
>Michael> class.  The init() method in HTML::Parser was added for that purpose.
>
>But still, this subroutine should work for that:
>
>    package MyClass;
>
>    sub new {
>       my $class = shift;
>       my $self = $class->SUPER::new(@_);
>       $self->my_init();
>       $self;
>    }
>
>If $self is not blessed into MyClass at this point, HTML::Parser is
>*broken*.  And MyClass->my_init should be found as well.
>
>And please stop using that broken "$proto = " template.  That
>mechanism adds unnecessary overhead and complexity to the 98% of uses
>that don't need it.  Put the instance-cloning protocol into ->clone or
>->copy, not ->new.
>
>-- 
>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
><[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
>See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Takeshi

Reply via email to