Great Circle Associates Majordomo-Users
(July 1998)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: Alphabitizing the subscription list
From: Jason L Tibbitts III <tibbs @ hpc . uh . edu>
Date: 15 Jul 1998 13:22:16 -0500
To: Ed Rogers <zulander @ rehtori . kasanen . fi>
Cc: majordomo-users @ GreatCircle . COM
In-reply-to: Ed Rogers's message of "Sat, 11 Jul 1998 23:46:45 +0200 (GMT+0200)"
References: <Pine.LNX.3.95.980711234505.23312C-100000@rehtori.kasanen.fi>

>>>>> "ER" == Ed Rogers <zulander@rehtori.kasanen.fi> writes:

ER> Anyone know of a quick and easy way to alphabatize a LONG list of
ER> subscribers on a list without doing it by hand?

Here's my 'mungelist' script which can strip comments and sort a list.  It
doesn't alphabetize it, though; you need to define what 'alphabetic' means,
else you'll get a lot of addresses starting with '<' at the top.  Instead
this script sorts things such that all, say, AOL addresses cluster
together.  It's easy to change that order, though.

Perl5 and MailTools required.

 - J<

#!/usr/local/bin/perl5 -w
use strict;
my($addr, $domain, $revdomain, $triple, @triples);

use Getopt::Std;
use Mail::Address;

getopts('ot');

unless ($::opt_o || $::opt_t) {
  print <<"EOF";
Usage $0 [OPTION]... [ADDRESS FILE]

 -o  sOrt the list of addresses
 -t  sTrrip comments from the addresses

 Both sorting and stripping may be specified.
EOF
  exit(0);
}

open(FILE,$ARGV[0]);

while (<FILE>) {
  chomp;
  $addr = Mail::Address::address(parse Mail::Address $_);
  ($domain = $addr) =~ s/(.*@|\[|\])//g;
  $revdomain = uc(join('.',reverse(split /\./,$domain)));
  
  push @triples,[$_, $addr, $revdomain];
}

close FILE;

if ($::opt_o) {
  @triples = sort {$a->[2] cmp $b->[2]} @triples;
}

for $triple (@triples) {
  if ($::opt_t) {
    print "$triple->[1]\n";
  }
  else {
    print "$triple->[0]\n";
  }
}



References:
Indexed By Date Previous: Re: mailing lists and MTA's
From: Dave Sill <de5@sws5.ctd.ornl.gov>
Next: Re: Alphabitizing the subscription list
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
Indexed By Thread Previous: Re: Alphabitizing the subscription list
From: Kynn Bartlett <kynn-mlists@idyllmtn.com>
Next: Re: Alphabitizing the subscription list
From: Allan Ku - Desktop Hardware Engineering <aku@ippon.East.Sun.COM>

Google
 
Search Internet Search www.greatcircle.com