473,543 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with "require" and multiple modules.

Don
I have a set of modules that all have the same interface, and package name:
_______________ _______________ _
package dataSourcePacka ge;

# Initialize global variables

$hashOne{'uniqu ekey1'} = "value1";
$hashOne{'uniqu ekey2'} = "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:
_______________ _______________ ___
../processDataSour ce dataSource1

(Which will do the following:)

require "/path/to/mods/ARGV[0]"; # I do have error testing this is just a
simplified version

@datapoints = dataSourcePacka ge::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";
dataSourcePacka ge::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 dataSourcePacka ge, it will start fresh? (NOTE: there are
a VERY large number of these dataSourcePacka ges, and it wouldn't be easy to
modify ALL the packages, any help would be greatly appreciated.)

Thanks,
Don.

Jul 19 '05 #1
2 2606
"Don" <pl************ *******@nerdlyc rap.com> wrote in message news:<1O******* **************@ twister.nyroc.r r.com>...
I have a set of modules that all have the same interface, and package name:
Bad idea.
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";
dataSourcePacka ge::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 dataSourcePacka ge, it will start fresh?
This is FAQ: "How do I clear a package?"

You'll also need to delete the entry in %INC.
(NOTE: there are
a VERY large number of these dataSourcePacka ges, and it wouldn't be easy to
modify ALL the packages, any help would be greatly appreciated.)


If the packages don't rely too many other modules at compile time you
could load each in it's own Safe compartment.

This newsgroup does not exist (see FAQ). Please do not start threads
here.
Jul 19 '05 #2
"Don" <pl************ *******@nerdlyc rap.com> wrote in message news:<1O******* **************@ twister.nyroc.r r.com>...
I have a set of modules that all have the same interface, and package name:
_______________ _______________ _
package dataSourcePacka ge;

# Initialize global variables

$hashOne{'uniqu ekey1'} = "value1";
$hashOne{'uniqu ekey2'} = "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:
_______________ _______________ ___
./processDataSour ce dataSource1

(Which will do the following:)

require "/path/to/mods/ARGV[0]"; # I do have error testing this is just a
simplified version

@datapoints = dataSourcePacka ge::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";
dataSourcePacka ge::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 dataSourcePacka ge, it will start fresh? (NOTE: there are
a VERY large number of these dataSourcePacka ges, and it wouldn't be easy to
modify ALL the packages, any help would be greatly appreciated.)

Thanks,
Don.


to enforce reoloading of the packages try to delete from the %INC hash :
delete $INC{"/path/to/mods/$datasource");

Ralph
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2977
by: Phil Powell | last post by:
I'm sorry but I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for...
4
2790
by: Mxsmanic | last post by:
The require() I'm using in a PHP script has stopped working after I moved from PHP4 and Apache 1.3.x to PHP5 and Apache 2.x. Now I get messages like this: Warning: main(/includes/ReloadScript.html) : failed to open stream: No such file or directory in /usr/local/www/htdocs/main/AOLCompression.php on line 14 Fatal error: main() : Failed...
15
6046
by: Michael | last post by:
Guten Morgen, I am implementing a script that my client wants on their website. Within the script there are several "require" statements. Any time one of these "require" statements is executed, the script terminates. Any ideas how I might solve this problem?
31
4813
by: Yeah | last post by:
Is it absolutely necessary to include "http://" in an A HREF hyperlink? Would it be wise to remove this from one's Links page, just to save code?
5
3199
by: Jim Carlock | last post by:
I've set up the following using an Alias in Apache... Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/" <Directory "C:/Apache/htdocs/common/docs/php"> Options Indexes FollowSymlinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory>
1
5037
by: yaru22 | last post by:
when I read a book, it just said we need to do import pygtk pygtk.require("2.0") import gtk in order to import gtk modules What is that pygtk.require("2.0") command for?
5
2194
by: lister | last post by:
Hi all, I have a fairly diverse range of data that I want to cache in the session rather than pulling it from the database on every page refresh. The problem is is that it seems that PHP requires the class definitions available on EVERY page, as it unserialises everything even if it's not going to be used.
0
7354
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5888
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4898
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3394
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
643
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.