On Mon, 1 May 2000, Richard Chen wrote:

> 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.

the problem is that Perl creates symbol table references at compile time,
Symbol::delete_package() wipes those references out of existence.
try using Apache::PerlRun->flush_namespace('Q'), which clears just
the values, and leaves the references in tact.

Reply via email to