I have a set of modules that all have the same interface, and package name:
_______________________________
package dataSourcePackage;
# Initialize global variables
$hashOne{'uniquekey1'} = "value1";
$hashOne{'uniquekey2'} = "value1";
sub requiredMethod1()
{
....
}
....
return 1;
_________________________________
The processing in each module is different, but the interface MUST remain
the same. I have scripts which call each module based on an input to the
script:
_________________________________
../processDataSource dataSource1
(Which will do the following:)
require "/path/to/mods/ARGV[0]"; # I do have error testing this is just a
simplified version
@datapoints = dataSourcePackage::getPoints(5);
# Process points.
_________________________________
My problem is I now have to write a script which runs multiple packages
during the same execution, and sometimes will call the same package twice.
The issue I am having is that most of the modules have hardcoded data in the
section I have marked as "Initialize global data", and contain hashes with
the same name. So when I do something like:
--------------------------------
foreach $datasource (@datasources)
{
require "/path/to/mods/$datasource";
dataSourcePackage::syncPoints(-1);
}
--------------------------
dataSource2 will try to access dataSource1 points, which causes runtime
errors. Is there a way to destroy a package after it is loaded, so that the
next time I load a dataSourcePackage, it will start fresh? (NOTE: there are
a VERY large number of these dataSourcePackages, and it wouldn't be easy to
modify ALL the packages, any help would be greatly appreciated.)
Thanks,
Don.