{ my $glob = gensym() ; ${*$glob} = 123 ; print "SCOPED: " . "${*$glob}\n" ; } print "OUT: " . ${*Symbol::GEN0} . "\n";
I don't think you quite understand what that is doing. At compile time, that *Symbol::GEN0 in the OUT line causes the GEN0 glob to be created and referred to directly by the compiled code. Then at runtime, gensym fetches and deletes it from the symbol table (skipping creating it since it's already there). Adding to your test:
use Symbol; print "Symbols: ", join(",",keys %Symbol::), "\n"; { my $glob = gensym() ; ${*$glob} = 123 ; print "SCOPED: " . "${*$glob}\n" ; } print "OUT: " . ${*Symbol::GEN0} . "\n"; print "Symbols2: ", join(",",keys %Symbol::), "\n"; print "OUT2: ", ${"Symbol::GEN0"} . "\n";
gets you:
Symbols: qualify,geniosym,gensym,GEN0,EXPORT,EXPORT_OK,import,ungensym +,qualify_to_ref,EXPORT_FAIL,delete_package,ISA,BEGIN,VERSION SCOPED: 123 OUT: 123 Symbols2: qualify,geniosym,gensym,EXPORT,EXPORT_OK,import,ungensym,qua +lify_to_ref,EXPORT_FAIL,delete_package,ISA,BEGIN,VERSION OUT2:
About the undef of types, I don't remember ever seeing your actual tests, and I wasn't able to deduce anything useful from your Safe::World. If undefing the individual parts of the glob is freeing more than undefing the whole glob, it is a bug and sample code showing it in action would be very welcome.

In reply to Re: Re: Re: Re: undefining one slot of a typeglob by ysth
in thread undefining one slot of a typeglob by AidanLee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.