2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 16:56:04 +00:00

: minor code cleanup

git-svn-id: https://svn.fhem.de/fhem/trunk@21553 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2020-03-31 11:32:00 +00:00
parent e808ff4abc
commit b22d53a58d

View File

@ -10,18 +10,18 @@ use configDB;
no if $] >= 5.017011, warnings => 'experimental'; no if $] >= 5.017011, warnings => 'experimental';
sub CommandConfigdb($$); sub CommandConfigdb;
sub _cfgDB_readConfig(); sub _cfgDB_readConfig();
my @pathname; my @pathname;
sub configdb_Initialize($$) { sub configdb_Initialize {
my %hash = ( Fn => "CommandConfigdb", my %hash = ( Fn => "CommandConfigdb",
Hlp => "help ,access additional functions from configDB" ); Hlp => "help ,access additional functions from configDB" );
$cmds{configdb} = \%hash; $cmds{configdb} = \%hash;
} }
sub CommandConfigdb($$) { sub CommandConfigdb {
my ($cl, $param) = @_; my ($cl, $param) = @_;
my @a = split("[ \t][ \t]*", $param); my @a = split("[ \t][ \t]*", $param);
@ -106,7 +106,7 @@ sub CommandConfigdb($$) {
Log3 (4,undef,"configDB: exporting $f"); Log3 (4,undef,"configDB: exporting $f");
my ($path,$file) = $f =~ m|^(.*[/\\])([^/\\]+?)$|; my ($path,$file) = $f =~ m|^(.*[/\\])([^/\\]+?)$|;
$path = "/tmp/$path"; $path = "/tmp/$path";
eval qx(mkdir -p $path) unless (-e "$path"); eval { qx(mkdir -p $path) } unless (-e "$path");
$ret .= _cfgDB_Fileexport $f; $ret .= _cfgDB_Fileexport $f;
$ret .= "\n"; $ret .= "\n";
} }
@ -241,17 +241,17 @@ sub CommandConfigdb($$) {
} }
sub _cfgDB_readConfig() { sub _cfgDB_readConfig() {
if(!open(CONFIG, 'configDB.conf')) { if(!open(my $CONFIG, '<', 'configDB.conf')) {
Log3('configDB', 1, 'Cannot open database configuration file configDB.conf'); Log3('configDB', 1, 'Cannot open database configuration file configDB.conf');
return 0; return 0;
} }
my @config=<CONFIG>; my @config=<$CONFIG>;
close(CONFIG); close($CONFIG);
use vars qw(%configDB); use vars qw(%configDB);
my %dbconfig; my %dbconfig;
eval join("", @config); eval { join("", @config) };
my $cfgDB_dbconn = $dbconfig{connection}; my $cfgDB_dbconn = $dbconfig{connection};
my $cfgDB_dbuser = $dbconfig{user}; my $cfgDB_dbuser = $dbconfig{user};