>>>>> "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:
|
|