http://qs321.pair.com?node_id=331329


in reply to Re: undefining one slot of a typeglob
in thread undefining one slot of a typeglob

it didn't occur to me that i didn't have to use a typeglob as my holder. good idea, and although it's a core module, this approach means i have one less use statement. Can anybody tell me why do 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} ;}
instead of this:
($type eq 'IO') ? close *{$glob} : undef *{$glob}{$type};
and i have to wonder if just using this would not work:
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.