# home.conf
package MyPackage;
my %config = (
WIKI_TITLE => 'MyWiki',
DEFAULT_TARGET => 'WelcomeToMyWiki',
DEFAULT_ACTION => 'view',
# etc.
);
sub get_config {
return %config;
}
1;
####
require 'home.conf'; # I'm not crazy about this name
# ...
my %config = MyPackage::get_config(); # copy of original hash
my $frobozz = foobar( $config{ WIKI_TITLE } );
####
package MyPackage;
my %config = (
# as before
);
sub config {
my $config_param = shift;
if ( defined $config{ $config_param } ) {
return $config{ $config_param };
}
else {
die "Unknown configuration parameter: $config_param";
}
}
1;
####
require 'home.conf';
# ...
my $frobozz = foobar( MyPackage::config( 'WIKI_TITLE' ) );
####
require 'home.conf';
# ...
*config = \&MyPackage::config; # make an alias
my $frobozz = foobar( config( 'WIKI_TITLE' ) );