R
Robert Billing
I have a fairly large suite of Perl scripts, and a configuration file
called db_config.pl which has some "configuration parameters" such as
where things are in the file tree, names of databases and tables and so
on. The intention is that this small file can be edited manually if needed.
When a stand-alone script is run it executes
require "db_config.pl" ;
which pulls in the definitions. This worked beautifully until I decided
that one new feature was best implemented as an object.
I therefore set up a package, let's call it dbadmin, which provides
methods to create an object, do something with it and finally output it
as HTML for display. This also works perfectly.
The problem is that if I require the configuration in main namespace it
is invisible in dbadmin and vice versa. If I put in two require
statements the clever behaviour of require means that only one does
anything.
At the moment I am getting at the definitions by writing things like
$Main::blivit, but is there a better, cleaner way of doing this?
Or in other works can I create a variable which is visible in all
namespaces?
called db_config.pl which has some "configuration parameters" such as
where things are in the file tree, names of databases and tables and so
on. The intention is that this small file can be edited manually if needed.
When a stand-alone script is run it executes
require "db_config.pl" ;
which pulls in the definitions. This worked beautifully until I decided
that one new feature was best implemented as an object.
I therefore set up a package, let's call it dbadmin, which provides
methods to create an object, do something with it and finally output it
as HTML for display. This also works perfectly.
The problem is that if I require the configuration in main namespace it
is invisible in dbadmin and vice versa. If I put in two require
statements the clever behaviour of require means that only one does
anything.
At the moment I am getting at the definitions by writing things like
$Main::blivit, but is there a better, cleaner way of doing this?
Or in other works can I create a variable which is visible in all
namespaces?