SplitPeriod
ListMonth
ListNewsgroups
+ ParseHierarchies
ReadGroupList
OutputData
FormatOutput
### 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;
};
################################################################################
next if($TLH and !/^$TLH/);
# don't count invalid newsgroups
if(%ValidGroups and !defined($ValidGroups{$_})) {
- &Bleat(1,sprintf("DROPPED: %s",$_));
+ warn (sprintf("DROPPED: %s\n",$_));
next;
}
# add original newsgroup to %Newsgroups
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;
sub ListMonth {
################################################################################
### return a list of months (YYYY-MM) between start and end month
-### IN : $StartMonth, $EndMonth
-### OUT: @Months: array containing all months from $StartMonth to $EndMonth
- my ($StartMonth, $EndMonth) = @_;
- return (undef,undef)
- if ($StartMonth !~ /^\d{4}-\d{2}$/ or $EndMonth !~ /^\d{4}-\d{2}$/);
- # return if $StartMonth = $EndMonth
- return ($StartMonth) if ($StartMonth eq $EndMonth);
+### IN : $MonthExpression ('YYYY-MM' or 'YYYY-MM to YYYY-MM')
+### OUT: @Months: array containing all months from $MonthExpression enumerated
+ my ($MonthExpression )= @_;
+ # return if single month
+ return ($MonthExpression) if ($MonthExpression =~ /^\d{4}-\d{2}$/);
+ # parse $MonthExpression
+ my ($StartMonth, $EndMonth) = split(' to ',$MonthExpression);
# set $Year, $Month from $StartMonth
my ($Year, $Month) = split /-/, $StartMonth;
# define @Months