sfink has asked for the wisdom of the Perl Monks concerning the following question:
Context: I have an application with an embedded perl interpreter. To simplify the explanation, let's say the application is a "page browser", where each page happens to be written in Perl. In order to keep the pages from colliding with each other, I generate a unique package name for each page, and compile the page within that package. (If the page chooses to set its own package, then it's expected to know how to deal with the consequences.)
So far, so good. But when I switch away from a page, I want to clean things up. I don't want to just nuke the interpreter and create a new one, because there is some shared state in the application itself that I don't want to lose. So I'd like to be able to wipe out the entire package I created, and have the package variables' DESTROY methods called if applicable. (I would also kind of like the interpreter to forget about any required files, so that when I went back to the page, it would do the same thing it did the first time. But those files could manipulate global state, so I'd better not. I'll stick with use'ing things so that they'll just re-import stuff when reactivated.)
Is there some way to do this? Or am I approaching this the wrong way? General advice is appreciated too.
I have tried a couple variations of delete $main::{"MYPACKAGE::"}, but no luck so far.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deleting a package
by broquaint (Abbot) on Apr 27, 2004 at 08:06 UTC | |
by sfink (Deacon) on Apr 27, 2004 at 17:02 UTC | |
|
Re: Deleting a package
by Fletch (Bishop) on Apr 27, 2004 at 02:39 UTC | |
|
Re: Deleting a package
by adrianh (Chancellor) on Apr 27, 2004 at 08:34 UTC | |
by halley (Prior) on Apr 27, 2004 at 13:29 UTC | |
by adrianh (Chancellor) on Apr 27, 2004 at 13:59 UTC | |
by halley (Prior) on Apr 27, 2004 at 14:04 UTC | |
by adrianh (Chancellor) on Apr 27, 2004 at 15:53 UTC | |
by sfink (Deacon) on Apr 27, 2004 at 17:17 UTC | |
by adrianh (Chancellor) on Apr 28, 2004 at 23:34 UTC | |
|
Re: Deleting a package
by bsb (Priest) on Apr 27, 2004 at 12:41 UTC | |
|
Re: Deleting a package
by nothingmuch (Priest) on Apr 27, 2004 at 14:40 UTC |