439
|
0 |
2 |
0 |
$$OBJS{$section} ||= do {
my $config = $CONF{$section};
my(%args) = ();
foreach my $key (keys %{$config;}) {
if ($key =~ s/^\@//) {
$args{$key} = $$config{"\@$key"};
}
elsif ($key =~ s/^\$//) {
$args{$key} = $$config{"\$$key"}[0];
}
else {
$args{$key} = $$config{$key}[0];
$args{"__$key"} = $$config{$key};
};
};
my $cons = delete $args{'%constructor'} || 'new';
my $class = delete $args{'%package'} || $args{'package'} || (return \%args);
my $args = delete $args{'%args'};
my $noargs = delete $args{'%noargs'} || 'false';
eval "use $class";
warn $@ if defined $@ and $@;
my $hashref = delete $args{'%hashref'} || 'false';
my(@args) = $args ? map({$args{$_};} split(/\s+/, $args, 0)) : %args;
if (lc $noargs eq 'true') {
$class->$cons;
}
elsif (lc $hashref eq 'true') {
$class->$cons({@args});
}
else {
$class->$cons(@args);
}
} |