X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=blobdiff_plain;f=NewsStats.pm;h=91a139621f82f2fc64c7a47ab1f76e2e5878db43;hp=f0a4066e1584eb9e3338a3f84907d39eba42daca;hb=db7696e550695219f00b24b19020f0c163e8c171;hpb=0dc13b3980d2bd4f0611be1bbeab05f1ea42c645 diff --git a/NewsStats.pm b/NewsStats.pm index f0a4066..91a1396 100644 --- a/NewsStats.pm +++ b/NewsStats.pm @@ -33,6 +33,7 @@ require Exporter; SplitPeriod ListMonth ListNewsgroups + ParseHierarchies ReadGroupList OutputData FormatOutput @@ -98,7 +99,19 @@ sub ReadConfig { ### IN : $ConfFile: config filename ### OUT: reference to a hash containing the configuration my ($ConfFile) = @_; - return Config::Auto::parse($ConfFile, format => 'equal'); + # mandatory configuration options + my @Mandatory = ('DBDriver','DBHost','DBUser','DBPw','DBDatabase', + 'DBTableRaw','DBTableGrps'); + # read config via Config::Auto + my $ConfR = Config::Auto::parse($ConfFile, format => 'equal'); + my %Conf = %{$ConfR}; + # check for mandatory options + foreach (@Mandatory) { + &Bleat(2,sprintf("Mandatory configuration option %s is not set!",$_)) + if (!defined($Conf{$_})); + } + # $Conf{'TLH'} is checked in gatherstats.pl + return $ConfR; }; ################################################################################ @@ -230,8 +243,9 @@ sub ReadGroupList { my %ValidGroups; open (my $LIST,"<$Filename") or &Bleat(2,"Cannot read $Filename: $!"); while (<$LIST>) { - s/^(\S+).*$/$1/; + s/^\s*(\S+).*$/$1/; chomp; + next if /^$/; $ValidGroups{$_} = '1'; }; close $LIST;