short

You only deleted a stash entry pointing to the glob, not the glob which continues to exist as long as it is referenced in code.

long

A typeglob is a kind of hash with 6 fixed slots holding different data types² !

The scalar $n is the value referenced in the scalar slot of of the glob *n ¹

Think of a stash as a HoH  $pck{globname}{SCALAR} = \ 'value'

And like all Perl data *n is a C structure somewhere in memory and can be retrieved by its reference GLOBREF = \*n.

A symbol table is a hash holding names and references of such typeglobs.

Eg in your case

 %Foo:: = ( ..., "n"=> GLOBREF, ... )

The code print $n internally compiles to something like  print GLOBREF->{SCALAR} where GLOBREF was looked up in the stash at compile time and hardcoded into the OP-codes.

simplified analogy

globs and stashes are confusing, I tried to translate what is happening to HoHs.

Maybe that makes it clearer

BEGIN { # at compile time %stash =(); # 'package stash' $stash{n}{SCALAR} =undef; # $n first use ( i.e. our-declaration ) $n_glob = $stash{n}; # exists only hardcoded } # at runtime: execute compiled op-codes $n_glob->{SCALAR}=123; delete $stash{n}; print $n_glob->{SCALAR}; # > 123

So deleting the Stash entry didn't delete the underlying glob (it's still referenced)

Update: You only sabotaged introspection at run time or further compilations with eval('print $n') .

Cheers Rolf

PS: Je suis Charlie!

update

¹)

DB<104> $n=123 => 123 DB<105> *n{SCALAR} => \123

²) i.e. refs to SCALAR, ARRAY, HASH, CODE, IO, GLOB, FORMAT see perlref


In reply to Re: What delete from symbol table really means? (Deleting typeglob of a specified package) by LanX
in thread What delete from symbol table really means? (Deleting typeglob of a specified package) by Discipulus

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.