#!/usr/bin/perl -w # convert Majordomo list of subscribers to the Sympa subscribers file # written by Petr Prazak # changes: # 2002-06-03 - try to figure out the gecos field use strict; my $cnt_conv = 0; my $cnt_skip = 0; my $time = time(); my $list; my $file = shift || die "The path of Majordomo mailing list expected.\n"; if ($file =~ /.*\/(.*)$/) { $list = $1; } else { $list = $file; } print STDERR "Converting Majordomo list $list to the Sympa subscribers file\n"; &transform($file, "mail"); $file .= "-digest"; &transform($file, "digest"); print STDERR "$cnt_conv converted, $cnt_skip skipped.\n"; sub transform { my ($file, $recept) = @_; open (F, "<$file") || warn "Cannot open file: $!", return; LINE: while () { chomp; my $line = $_; my $addr; my $gecos; if ($line =~ /^(.+@[^\s]+)\s+\((.+)\)/) { # format e@mail (Name Surname) $addr = $1; $gecos = $2; } else { my @arr = split / /, $line, 2; # format e@mail Name Surname $addr = $arr[0]; $gecos = $arr[1]; } if (not $addr =~ /^(.+)@.+\..+/) { print STDERR "$addr not an email address, skipping\n"; ++$cnt_skip; next LINE; } if (not defined($gecos)) { $gecos = $1; } ++$cnt_conv; print "date $time\nemail $addr\ngecos $gecos\nreception $recept\nvisibility noconceal\n\n"; # print "QUIET ADD $list $addr $gecos\n"; } }