in reply to Re: undefining one slot of a typeglob
in thread undefining one slot of a typeglob
instead of this:if ($type eq 'SCALAR') { undef ${*{$glob}} ;} elsif ($type eq 'ARRAY') { undef @{*{$glob}} ;} elsif ($type eq 'HASH') { undef %{*{$glob}} ;} elsif ($type eq 'CODE') { undef &{*{$glob}} ;} elsif ($type eq 'IO') { close *{$glob} ;}
and i have to wonder if just using this would not work:($type eq 'IO') ? close *{$glob} : undef *{$glob}{$type};
update: I should note that completely eradicating the sub from memory isn't necessarily the problem here, as sometimes the created CODE glob is simply an alias from another package rather than a brand new anonymous sub.undef *{$glob}{$type};
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: undefining one slot of a typeglob
by gmpassos (Priest) on Feb 24, 2004 at 08:24 UTC |