For fear of sounding like Andy I won't say "ugh this is really annoying me now".....but it is :)
Like Links SQL I have a cgi script that calls an init() routine. The very first module inclusion in that script (apart from strict and lib) is my main module which loads the base class and my config module which imports $CONF.
The init() routine then assigns the config data to $CFG so that other modules can use my central package to import eg...
use MyPackage qw/$CFG/;
At the end of the init routine I've checked the value of $CFG and it is storing the data properly, however in one of my other modules, $CFG is empty causing an error.
This is getting on my nerves because as far as I can see $CFG is being created properly and also imported into the other module otherwise I'd get an import error.
So to try to make this clearer, here is the top of the cgi script:
use lib '/apache1/cgi-bin/dir';
use MyPackage;
local $SIG{__DIE__} = \&MyPackage::fatal;
MyPackage::init();
.....in MyPackage I have:
use vars qw/$IN $TPL $USER $CFG $DB $LANG_CACHE $DEBUG/;
use Support::Config qw/$CONF/;
....in init() I have (amongst other things):
$CFG = $CONF;
Then in the module causing the error:
So it _should_ be working. I don't see why it isn't.
The error is being generated by a CFG value being empty so a certain file can't be loaded because the path is wrong...so it is not like an import error meaning that CFG isn't importing properly, CFG is just blank.
The routine is also auto-loaded so hasn't even compiled until it is called, so by then $CFG should be defined.
Sigh.
It was actually working fine before as I was using:
use MyClass::Config qw/$CFG/;
....but stupidly decided to change it. Ugh.
Like Links SQL I have a cgi script that calls an init() routine. The very first module inclusion in that script (apart from strict and lib) is my main module which loads the base class and my config module which imports $CONF.
The init() routine then assigns the config data to $CFG so that other modules can use my central package to import eg...
use MyPackage qw/$CFG/;
At the end of the init routine I've checked the value of $CFG and it is storing the data properly, however in one of my other modules, $CFG is empty causing an error.
This is getting on my nerves because as far as I can see $CFG is being created properly and also imported into the other module otherwise I'd get an import error.
So to try to make this clearer, here is the top of the cgi script:
Code:
use strict; use lib '/apache1/cgi-bin/dir';
use MyPackage;
local $SIG{__DIE__} = \&MyPackage::fatal;
MyPackage::init();
.....in MyPackage I have:
Code:
use strict; use vars qw/$IN $TPL $USER $CFG $DB $LANG_CACHE $DEBUG/;
use Support::Config qw/$CONF/;
....in init() I have (amongst other things):
Code:
# Set the config. $CFG = $CONF;
Then in the module causing the error:
Code:
use MyPackage qw/$CFG/;So it _should_ be working. I don't see why it isn't.
The error is being generated by a CFG value being empty so a certain file can't be loaded because the path is wrong...so it is not like an import error meaning that CFG isn't importing properly, CFG is just blank.
The routine is also auto-loaded so hasn't even compiled until it is called, so by then $CFG should be defined.
Sigh.
It was actually working fine before as I was using:
use MyClass::Config qw/$CFG/;
....but stupidly decided to change it. Ugh.