> Hello,
> 
> I have an array that contains one reference per item.
> I need to clean up the things referenced by those references
> So..
> 1) Am I doing this correctly?
> 2) am I doing the CODE,IO correct
> 3) any other refs I'm overlooking?
> 
> for(@references_to_kill) {
>       undef ${$_} if ref($_) eq 'SCALAR';
>          undef @{$_} if ref($_) eq 'ARRAY';
>          undef %{$_} if ref($_) eq 'HASH';
>          undef *{$_} if ref($_) eq 'GLOB';
>       undef &{$_} if ref($_) eq 'CODE'; # is this right??
>          close $_ if ref($_) eq 'IO'; # is this right, what if it was 
> never opened? How can I check that?
> # any others,
> }

My question is why do you need to do this?  Generally it may indicate
either a problem with scoping or a design flaw.

>From perldoc perlref:

"Hard references are smart--they keep track of reference counts for you,
automatically freeing the thing referred to when its reference count
goes to zero.  (Reference counts for values in self-referential or
cyclic data structures may not go to zero without a little help; see
"Two-Phased Garbage Collection" in perlobj for a detailed explanation.)
If that thing happens to be an object, the object is destructed.  See
perlobj for more about objects."

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to