|Just another Perl shrine|
Re: more fun w/ HASh ref'sby jarich (Curate)
|on Nov 27, 2005 at 14:05 UTC||Need Help??|
G'day Hugh.Might I suggest, for starters, that writing your own config parsing code is probably a mistake already? While I'm certain we can help you to get it working, you might find an existing module such as Config::IniHash, Config::Tiny or Config::General a better solution, especially in the long term. For your case I'd probably recommend Config::IniHash.
When is the error occuring? During compilation? During runtime? Can you compile the code as follows (outside of a CGI session)?
If it's happening during runtime, is it happening when you read in the config file, or when you later try to access it? If it's when you later try to access it, use Data::Dumper to have a look inside the config hash. Is it behaving as you'd expect?
Try isolating the problem. Write a new program which reads in the config data and then accesses it as you want to. Try to make it as simple as possible, perhaps as below:
If that doesn't work, then you've got something we can more easily help you debug. If it does work, then chances are that your problem is not actually where you think it is.
Either way, I strongly recommend you have a look at the already existing configuration modules.
All the very best,jarich