> -----Original Message-----
> From: Gary Stainburn [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 08, 2001 8:47 AM
> To: [EMAIL PROTECTED]
> Subject: garbage collection - hashes
> 
> 
> Hi all,
> 
> If i do the following:
> 
> $trunk{$_}->{ddi}='1234567';
> $trunk{$_}->{extn}='378';
> $trunk{$_}->{cli}='32332323';
> .....
> delete $trunk{$_}
> 
> will this work okay, or will it leak memory?

That's fine. Look at it this way: $trunk{$_} is a reference to
an anonymous hash containing some data.

delete $trunk{$_} removes the entry from %trunk. Since it was
a reference to an anonymous hash, that hash's reference count
is decremented. Assuming there are no other references to that
hash (i.e. you didn't make a copy earlier like $foo = $trunk{$_}),
Perl will notice that and will release the anonymous hash.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to