Revision c599fef2
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/LxOfficeConf.pm | ||
---|---|---|
6 | 6 |
use Encode; |
7 | 7 |
|
8 | 8 |
sub read { |
9 |
my $file = -f 'config/lx_office.conf' ? 'config/lx_office.conf' : 'config/lx_office.conf.default'; |
|
10 |
read_config $file => %::lx_office_conf; |
|
9 |
read_config 'config/lx_office.conf.default' => %::lx_office_conf; |
|
11 | 10 |
_decode_recursively(\%::lx_office_conf); |
11 |
|
|
12 |
if (-f 'config/lx_office.conf') { |
|
13 |
read_config 'config/lx_office.conf' => my %local_conf; |
|
14 |
_decode_recursively(\%local_conf); |
|
15 |
_flat_merge(\%::lx_office_conf, \%local_conf); |
|
16 |
} |
|
12 | 17 |
} |
13 | 18 |
|
14 | 19 |
sub _decode_recursively { |
... | ... | |
23 | 28 |
} |
24 | 29 |
} |
25 | 30 |
|
31 |
sub _flat_merge { |
|
32 |
my ($dst, $src) = @_; |
|
33 |
|
|
34 |
while (my ($key, $value) = each %{ $src }) { |
|
35 |
if (!exists $dst->{$key}) { |
|
36 |
$dst->{$key} = $value; |
|
37 |
|
|
38 |
} else { |
|
39 |
map { $dst->{$key}->{$_} = $value->{$_} } keys %{ $value }; |
|
40 |
} |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
26 | 44 |
1; |
Auch abrufbar als: Unified diff
Konfigurationsdatei config/lx_office.conf.default immer einlesen; Daten aus config/lx_office.conf reinmergen