From: Moritz Bunkus Date: Wed, 9 Feb 2011 16:46:56 +0000 (+0100) Subject: Merge branch 'master' of lx-office.linet-services.de:lx-office-erp X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/7b4699d8d0b507359910ab47d91d5e3ab2c0b99a?hp=65b0e836c766dfbf937c8d81fb3361ae3cf5ed84 Merge branch 'master' of lx-office.linet-services.de:lx-office-erp --- diff --git a/SL/LxOfficeConf.pm b/SL/LxOfficeConf.pm index b0d801024..8f44016e6 100644 --- a/SL/LxOfficeConf.pm +++ b/SL/LxOfficeConf.pm @@ -6,9 +6,14 @@ use Config::Std; use Encode; sub read { - my $file = -f 'config/lx_office.conf' ? 'config/lx_office.conf' : 'config/lx_office.conf.default'; - read_config $file => %::lx_office_conf; + read_config 'config/lx_office.conf.default' => %::lx_office_conf; _decode_recursively(\%::lx_office_conf); + + if (-f 'config/lx_office.conf') { + read_config 'config/lx_office.conf' => my %local_conf; + _decode_recursively(\%local_conf); + _flat_merge(\%::lx_office_conf, \%local_conf); + } } sub _decode_recursively { @@ -23,4 +28,17 @@ sub _decode_recursively { } } +sub _flat_merge { + my ($dst, $src) = @_; + + while (my ($key, $value) = each %{ $src }) { + if (!exists $dst->{$key}) { + $dst->{$key} = $value; + + } else { + map { $dst->{$key}->{$_} = $value->{$_} } keys %{ $value }; + } + } +} + 1;