#!/usr/sww/bin/perl
$final_year = "19" . `/bin/date +%y`;
for ($year = 1995; $year <= $final_year; ++$year) {
    for ($month = 1; $month <= 12; ++$month) {
	$last_month = $month - 1;
	if ($last_month < 1) {
	    $last_month = 12;
	    $last_year = $year - 1;
	} else {
	    $last_year = $year;
	}
	$next_month = $month + 1;
	if ($next_month > 12) {
	    $next_month = 1;
	    $next_year = $year + 1;
	} else {
	    $next_year = $year;
	}
	if ($month < 10) {
	    $print_month = "0$month";
	} else {
	    $print_month = $month;
	}
	$outfile = "$year.$print_month.tar.gz";
	$arts = `/usr/sww/bin/pick -after $last_month/31/$last_year -and -before $next_month/01/$next_year +mlist-arch`;
	$arts =~ s/\n/ /g;
	if ($arts ne "0 ") {
	    system("cd `/usr/sww/bin/mhpath +mlist-arch`; /bin/tar cf - $arts | /usr/sww/bin/gzip -9 > $outfile; /bin/mv $outfile /private/ftp/pub/postgres/mail-archive");
	}
    }
}
