Yes, that's it. Thank you, Magnus.

But thinking a bit about it:
I thought Perl was taking care of objects, variables etc. that
don't have a reference pointing to them and destroy / delete
them immediately, or is this not true for blessed objects?

Regards,
---------------------------------------------------------------------------------------
Gerhard Petrowitsch                                Tel.: +49 8151 270 126
SP3D Chip Design GmbH                    Fax:  +49 8151 270 200
Petersbrunnerstr. 17                Home Office: +49 821 9069 741
82319 Starnberg, Germany      SERI: gerhard@DESTNSC1
---------------------------------------------------------------------------------------
Be like the ant.  When the ant gets a mixture of sand and sugar,
it selects only sugar; it neglects sand. See only good in others.
Pay no attention to the bad.                                (Sathya Sai Baba)
--------------------------------------------------------------------------------------------


                                                                                       
                                                                             
                                                                                       
                                                                             
                                                   To:   Gerhard 
Petrowitsch/STN/SC/PHILIPS@EMEA1                                                       
            
                                                   cc:                                 
                                                                             
                                                   Subject:    Re: OO question         
                                                                             
                                                                                       
                                                                             
               "Magnus Lindgren"                   Classification:                     
                                                                             
               <[EMAIL PROTECTED]>                                                     
                                                                             
                                                                                       
                                                                             
               28.01.2003 11:23                                                        
                                                                             
                                                                                       
                                                                             
                                                                                       
                                                                             




Hi!

You only delete the reference to the object, not the object itself. What you have to 
do is a recursive delete function as well. Something like:

$top->{_var}{name1}->delete();

And then define this method to first call delete on all it's children and then delete 
itself and finaly delete the reference itself:

delete $top->{_var}{name1};

I may be wrong or there may be a simpler way but this is what I would have done.

Regards, Magnus


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 28, 2003 11:00 AM
Subject: OO question


> Hi all,
>
> I've got a little object-oriented programming question:
>
> I've built a class that recursively creates instances of itself,
> storing them in itself.
>
> $top = MyClass->new();
> $top->{_var}{name1} = MyClass->new();
>
> and so on, down a number of levels, creating a tree.
>
> If I now delete one of the entries from a higher levels, that
> contains objects in lower levels, like
>
> delete $top->{_var}{name1};
>
> I would expect, that all the objects down the Hierarchy would
> be destroyed, but this is not the case.
>
> Why?
> 
>---------------------------------------------------------------------------------------
> Gerhard Petrowitsch                                Tel.: +49 8151 270 126
> SP3D Chip Design GmbH                    Fax:  +49 8151 270 200
> Petersbrunnerstr. 17                Home Office: +49 821 9069 741
> 82319 Starnberg, Germany      SERI: gerhard@DESTNSC1
> 
>---------------------------------------------------------------------------------------
> Be like the ant.  When the ant gets a mixture of sand and sugar,
> it selects only sugar; it neglects sand. See only good in others.
> Pay no attention to the bad.                                (Sathya Sai Baba)
> 
>--------------------------------------------------------------------------------------------
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>




_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to