my $cfg = App::Config->new({
'CASE' => 0
});
$cfg->define("effective_group", {
'DEFAULT' => "nogroup"
});
$cfg->define("effective_user", {
'DEFAULT' => "nobody"
});
$cfg->define("http_port", {
'DEFAULT' => "localhost:8080",
'CMDARG' => [ "-p" ],
'ARGCOUNT' => 1
});
####
my $cfg = Local::Config->new({
'CASE' => 0
}, {
'effective_group' => {
'DEFAULT' => "nogroup"
},
'effective_user' => {
'DEFAULT' => "nobody"
},
'http_port' => {
'DEFAULT' => "localhost:8080",
'CMDARG' => [ "-p" ],
'ARGCOUNT' => 1
}
});
####
package Local::Config;
use strict;
use vars qw/$VERSION @ISA @EXPORT @EXPORT_OK/;
require Exporter;
require AutoLoader;
@ISA = qw/Exporter AutoLoader/;
@EXPORT_OK = qw//;
$VERSION = '0.24';
use App::Config;
sub define {
my $self = shift;
return undef unless defined $self->{config};
my $arg = @_;
if (ref($arg) eq 'HASH') {
$self->{config}->define($_, ${$arg}{$_}) foreach keys %{$arg};
};
return;
};
sub get {
my $self = shift;
return $self->{config}->get(@_);
};
sub load ($) {
my $self = shift;
return undef unless -e $_[0];
return $self->{config}->cfg_file($_[0]);
};
sub new {
my $param = shift;
my $class = ref($param) || $param;
my $self = {};
bless ($self, $class);
my $args = (ref($_[0]) eq 'HASH') ? $_[0] : {};
$self->{config} = App::Config->new(\%{$args});
if (ref($_[1]) eq 'HASH') {
$self->{config}->define($_, ${$_[1]}{$_}) foreach keys %{$_[1]};
};
return $self;
};
sub set {
my $self = shift;
return $self->{config}->set(@_);
};
1;
__END__