]> wagnertech.de Git - mfinanz.git/blobdiff - SL/LxOfficeConf.pm
config/lx_office.conf.default einlesen, wenn config/lx_office.conf nicht existiert
[mfinanz.git] / SL / LxOfficeConf.pm
diff --git a/SL/LxOfficeConf.pm b/SL/LxOfficeConf.pm
new file mode 100644 (file)
index 0000000..b0d8010
--- /dev/null
@@ -0,0 +1,26 @@
+package SL::LxOfficeConf;
+
+use strict;
+
+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;
+  _decode_recursively(\%::lx_office_conf);
+}
+
+sub _decode_recursively {
+  my ($obj) = @_;
+
+  while (my ($key, $value) = each %{ $obj }) {
+    if (ref($value) eq 'HASH') {
+      _decode_recursively($value);
+    } else {
+      $obj->{$key} = decode('UTF-8', $value);
+    }
+  }
+}
+
+1;