Fellow Monks,
I have a fairly large Perl application for which I need to reduce the memory size (program is currently at 10M/process on my Win32 box; multiple processes may run the program). This program is naturally broken down into several packages, all of which are 'use'd at the top of the starting Perl file; e.g.
use Alpha;
use Beta;
use Gamma;
use Delta;
Of course, the Alpha package itself 'use's a bunch of other packages, which in turn use other packages, etc. So Alpha might begin with something like
package Alpha;
use Rho;
use Sigma;
use Tau;
use Delta;
However, a
lot of these packages are never used, depending on the many arguments that the user can pass in at runtime. For instance, Alpha and Beta are mutually exclusive. I thus replaced the first section of code with something like
use Gamma;
use Delta;
# Argument parsing here
if ([user specified Beta]) {
require Beta;
import Beta;
# make Beta calls
} else {
require Alpha;
import Alpha;
# make Alpha calls
}
This save me around a half meg of RAM. Coolness. I'd like to be able to employ similar logic on all my packages. I thus need for any other package required by my program to be able to access the hash in the main namespace, which is where those command line options are currently being stored. Does anyone know of a way to do this, or another approach I can use to solve this problem? I've considered shoving the data into %INC or the like, but this seems pretty hacky and fairly error-prone.
Any help would be appreciated.
-Ton
-----
Be bloody, bold, and resolute; laugh to scorn
The power of man...