Hi,
I'm trying to apply code and have problems. Would kindly ask for help.
I have this in Log.conf :
# Defines logging groups in terms of room: if device's room maatches r
+oom name or if device name is listed separately in hash, then is logg
+ed into same log:
%Log_rooms = (
"gallery" => { 'BM_shutts_south_00' => 1, 'BM_shutt_no
+rth_00' => 1 },
"kitchen" => { },
"office" => { },
"living" => { },
"utility" => { },
"kurilnica" => {},
"lobby" => { },
"toilet" => { }
);
I'd like to read that hash definition into Perl program :
use Data::Dumper;
use Safe;
my %Log_rooms;
my $config_file ="./Log.conf";
if (-e $config_file) {
print "File Exists!";
# my $comp = new Safe;
# my $return =$comp->reval($config_file);
my $return = do $config_file ;
warn "couldn't parse $config_file: $@" if $@;
warn "couldn't do $config_file: $!" unless defined $return;
warn "couldn't run $config_file" unless $return;
} else {
%Log_rooms = (
"default" => { 'BM_shutts_south_00' => 1, 'BM_shutt_no
+rth_00' => 1 }
);
};
print "###############################################################
+#################\n";
print Data::Dumper::Dumper(%Log_rooms);
but I don't get anything in %Log_rooms (default works if config file is missing).
I'd also like to implement safer way with using Safe, but it also doesn't work. I'd kindly ask for some help...
Thanks in advance,
Rob.
|