Hello,
I am having a problem clearing variables and aliases
in a temporary package name space. The source of the problem
is in making legend cgi scripts work under Apache::Registry.
But the problem can be isolated and shown by the following
demo program:
$ cat foo.cgi
#!/usr/bin/perl -w
use strict;
use Symbol qw(delete_package);
print "Content-type: text/plain\n\n";
%Q::userdata=();
$Q::userdata{first_name}='first_name';
$Q::userdata{last_name}='last_name';
*Q::hello=\&hello;
print "here is the symbol table\n";
while (my($k,$v)=each %Q::) {
print "$k => $v\n";
}
delete_package('Q');
sub hello {
print "hi\n";
}
The first time it runs, it yields:
here is the symbol table
userdata => *Q::userdata
hello => *Q::hello
But there after, modperl shows emtpy symbol table.
In my actual implementation, delete_package is used
inside a PerlCleanupHandler. But the behavior is the
same: the symbol table is completely gone even if
I reinitialize the variables and aliases at the start
again.
Does anyone know a way around this? In perlfaq7
another method using scrub_package is mentioned.
But that one is not appropriate because if a subroutine
is aliased, that scrub_package will make the original
subroutine undefined, causing havoc all over the place.
Thanks for any info.
Richard