perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon <three1...@gmail.com>
Subject Re: About config file
Date Thu, 07 Mar 2013 04:21:36 GMT
Is there any reason he can't use Config::Any?
http://search.cpan.org/~bricas/Config-Any-0.23/lib/Config/Any.pm

Then he can load his json structures directly (via .json file) or load
variables from a .pl file.

Maybe I've missed the scope of the problem, but op's example immediately
made me think he's trying to build config files as classes. While you could
use moose (Or mouse, or moo, etc.) And build your config options as
parameters, e.g.:

package My::Config
use Moose;

has 'param1' => (
    is => 'ro',
    isa => 'Str',
    default => 'Bob',
);

Then later

package main;

my $cfg = My::Config->new;
do_stuff $cfg->param1, '12';

Or whatever method invocation would make use of those variables.

Config::Any effectively gives you an OO interface to your config file
without having to build the class by hand.

Admittedly, the last project I had that used mod_perl was a long time ago,
and I've just stayed subscribed to this list because I really enjoy most of
your discussions (and typically learn a thing or two) so this probably
isn't the most canonical "mod_perl" thinking...

I think it's a good solution because it provides a "simple" interface to
complex config files. But would really like to understand the flaws in my
thinking if you're going to shoot me down.

Thanks,
Jon A
On Mar 6, 2013 8:19 PM, "Ken Peng" <yhpeng@orange.fr> wrote:

> 于 2013-3-7 11:15, Jie Gao 写道:
>
>> You can follow this:
>>
>>      http://perl.apache.org/docs/2.**0/devel/core/coding_style.html<http://perl.apache.org/docs/2.0/devel/core/coding_style.html>
>>
>> if you are after a standard coding style.
>>
>> Regards,
>>
>
>
> Thanks. but I don't think it's something about coding style.
>
>

Mime
View raw message