#! /bin/perl
# Copyright(C) 2001 by Yuh.N
# $Id: generate_optimized_member_ph.pl,v 1.2 2001/01/04 13:53:17 yuh Exp $

require '/usr/local/ppml/sitedef.ph';

opendir(MLD, $ML_SETTING_ROOT) || die $!;
@dirlist = grep ! /^\./, readdir(MLD);
closedir(MLD);

%allmembers = ();
foreach $ml (sort @dirlist) {
    next if (! -f "$ML_SETTING_ROOT/$ml/members.ph");

    do "$ML_SETTING_ROOT/$ml/members.ph";

    foreach $email (keys %members) {
	if (! defined($allmembers{$email})) {
	    $allmembers{$email} = sprintf("'%s',\t", $members{$email});
	}
	$allmembers{$email} .= sprintf("'%s', ", $ml);
    }
    
}

printf("%members =(\n");
foreach $email (keys %allmembers) {
    chop($allmembers{$email});
    printf("'%s'\t => [%s],\n", $email, $allmembers{$email});
}
printf(");\n1;\n");

exit(0);
