#!/usr/local/bin/perl
# convert memdata --> memlist
#
# Each entry in memdata should start with a line of the form:
#
# LastName, FirstName
#
# or
#
# LastName>LastName, FirstName
#
#
# The data should be on a single line (use canon.pl to merge multiple lines).
# The line must be preceded by an empty line.
# There should be no other empty lines.
$memfilename = "memdata";
open LIST, ">t/memlist";
while(<>){
chop;
($tagtype, $address, $name) = /^.*(.+)<.+/;
if ($s) { # previous line was empty
if (/^\s*$/) { next;} # skip extra empty lines
# diagnose some common errors:
if (!$tagtype || !$address || !$name) {
print STDERR "malformed line: -->$_<--\n";
print STDERR "(previous record was: -->$last_address<--)\n";
exit(1);
}
$last_address = $address;
if ($tagtype eq "name") {
print LIST "
$name\n\n";
} elsif ($tagtype eq "href") {
print LIST "
$name\n\n";
} else {
print STDERR "unexpected tag type: >$tagtype<\n"; exit(1);
}
}
$s = /^\s*$/;
}