I tried using Exporter as you described above (great example, thanks) but Apache/mod_perl kept complaining that :all wasn't being exported.
I gave up on this after a while and am trying to simply use our and call the vars with $Config::var. I'm getting the same error as before and there are no values associated with the variables. I added a print STDERR "database is $Config::database\n"; to demonstrate.
Snippet from Config.pm:
package Config.pm; use strict; ########################### # user options # ########################### our $database = 'data/site.db'; our $tmplfile = 'templates/index.html';
A couple snippets from index.cgi:
use strict; my $database = $Config::database; my $tmplfile = $Config::tmplfile; ... print STDERR "FOOBAR $Config::database\n"; my $template = HTML::Template->new(filename => $tmplfile, die_on_bad_p +arams => 0);
And the error:
FOOBAR [Sun Sep 6 05:30:35 2009] [error] PerlRun: `HTML::Template->new() cal +led with odd number of option pa rameters - should be of the form option => value at /blogapp/index.cgi + line 29\n'
In reply to Re^2: Using packages to store global configuration vars
by fuzzyping
in thread Using packages to store global configuration vars
by fuzzyping
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |