#!/usr/local/bin/perl

open( LYNX, "lynx -dump http://www.uiuc.edu/ph/www/tskirvin/global/global.gen|" )
	|| die "open(lynx)\n";

while( <LYNX> ) { last if /^==Generic Global Killfile==/ }

$state = 'prename';
print <<EOT;
# This nn killfile has been automatically generated by 
# global.nn.pl. You should probably rerun this script rather than 
# editing this file directly.  The Global Killfile is located at:
# http://www.uiuc.edu/ph/www/tskirvin/global/
# This script can be found at:
# http://www.uiuc.edu/ph/www/tskirvin/global/global.pl
# This (alpha) script is based off of a script by Brian Edmonds (with 
# permission) for use with the Internet blacklist.  The original script 
# can be found at:
# http://www.cs.ubc.ca/spider/edmonds/usenet/gnus/blacklist.pl

EOT

while( <LYNX> ) {
  last if /^==Generic Global Killfile End==/;
  if( /^Name:\s+(.*)/ ) {
    $state = 'premail'; $name = $1;
  } elsif( $state eq 'premail' && /^Alias:\s+(.*)/ ) {
    $state = 'inemail';
#    print "  ;; $name\n";
    for $f (split(/,/,$1)) {
      $f = $1;
#      $f =~ s/^\s|\s$//g; $f =~ s/^,|,$//g;
      print ":!n:$f\n";
#      print "  (\"$f\" -10000 nil s)\n";
    }
  } elsif( $state eq 'inemail' && /^\s+(.*)/ ) {
    for $f (split(/,/,$1)) {
       $f = $1;
#      $f =~ s/^\s|\s$//g; $f =~ s/^,|,$//g;
      print ":!n:$f\n";
#      print "  (\"$f\" -10000 nil s)\n";
    }
  } elsif( $state eq 'inemail' ) {
    $state = 'prename';
  }
} close LYNX;

# print "))\n";

# EOF
