perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Prime <adam.pr...@utoronto.ca>
Subject Re: About config file
Date Thu, 07 Mar 2013 15:03:44 GMT
On 03/06/2013 11:21 PM, Jon wrote:
>
> Is there any reason he can't use Config::Any?
> http://search.cpan.org/~bricas/Config-Any-0.23/lib/Config/Any.pm
> <http://search.cpan.org/%7Ebricas/Config-Any-0.23/lib/Config/Any.pm>
>
>

There's no reason why he can't use any Config package, or roll his own
using json, or yaml, or whatever format he prefers.

It could be as simple as this:

package MyConfig;

use Sub::Exporter -setup => { exports => [ qw(get_config) ] };

use YAML::Syck;

my $config;

sub get_config {
    if (defined($config)) {
        return $config
    }
    $config = LoadFile('/www/etc/lolol.com/site.yaml');
    return $config
}

1;

This particular version will only load the file once, so if you change
the config you need to kick the webserver, but you can tailor this, or
any solution to suit whatever your needs are.

Adam

Mime
View raw message