friedo has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Data::Dumper; my $var = "Yak"; ${ 'Yakkity::' . $var . '::a' } = 42; print "a = $Yakkity::Yak::a\n"; print Dumper \%Yakkity::Yak::; print "Undeffing symbol table\n"; undef %Yakkity::Yak::; print "a = $Yakkity::Yak::a\n"; print Dumper \%Yakkity::Yak::; print "Undeffing glob\n"; undef *Yakkity::Yak::a; print "a = $Yakkity::Yak::a\n"; print Dumper \%Yakkity::Yak::;
And the output:
a = 42 $VAR1 = { 'a' => *Yakkity::Yak::a }; Undeffing symbol table a = 42 $VAR1 = {}; Undeffing glob a = $VAR1 = {};
So, what's going on here? How does perl know how to find $Yakkity::Yak::a after the package's symbol table is gone? Shouldn't *Yakkity::Yak::a have been deleted with it? Or does another reference to it exist outside the symbol table? If so, where? Suppose I were creating dynamic packages at runtime and I want to make sure all the stuff in them gets destroyed. How would I ensure that?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Undefining symbol tables and globs and things, oh my
by PodMaster (Abbot) on Aug 10, 2005 at 07:58 UTC | |
by ikegami (Patriarch) on Aug 10, 2005 at 13:49 UTC | |
by PodMaster (Abbot) on Aug 10, 2005 at 17:25 UTC | |
|
Re: Undefining symbol tables and globs and things, oh my
by dave_the_m (Monsignor) on Aug 10, 2005 at 12:44 UTC | |
by ikegami (Patriarch) on Aug 10, 2005 at 13:56 UTC | |
|
Re: Undefining symbol tables and globs and things, oh my
by Bob9000 (Scribe) on Aug 10, 2005 at 12:46 UTC | |
|
Re: Undefining symbol tables and globs and things, oh my
by broquaint (Abbot) on Aug 10, 2005 at 15:02 UTC |