Ovid has asked for the wisdom of the Perl Monks concerning the following question:
In a recent Usenet post, a person had a problem with an application that loads Perl, produces reports, but doesn't unload Perl. As a result, some of the Perl libraries that he uses have global variables that stick around and he wants to know to to reset those to their pristine state. After some discussion in the CB, Fletch suggested reset. It seems good, but it would also overwrite any default values. Ignoring this for a moment, the CB Monks came up with the following (assuming the variables are all lower case):
my @package = qw/ foo bar foo::bar /; foreach my $package ( @packages ) { eval "package $package; reset 'a-z'"; }
That seems to work, but I lose the initial state of the package variables. Anyone know of a simple way to do that without walking through symbol tables, checking the ref results and grabbing the values?
I'm actually thinking this might be a nifty module to reset symbol tables to their initial state rather than just clear them out.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Maintaining Symbol table state.
by chromatic (Archbishop) on Dec 07, 2001 at 00:00 UTC | |
by Ovid (Cardinal) on Dec 07, 2001 at 00:38 UTC |