I am concatenating several e-mail lists into one, and some of the addresses
are on multiple lists. I need to be able to print out a full, alphabetically
sorted list of all the names without printing duplicates. How would I alter
the following to make that happen?

This gets close; it *will* remove a duplicate address if there are only two
of the same address. But it won't work if there are three or four of the
same address, for example.

I'm also sure this could be shortened or cleaned up; suggestions welcome....


#!/usr/bin/perl -w

use strict;
my $infile = '/path/to/.biglist.list';
my @slurped = ();
open(IN,"<$infile");
while(<IN>) {
 @slurped = <IN>; # Pull addresses into an array
}
close(IN);

my @sorted = sort(@slurped); # Create a sorted list
my $i;
my $j;
foreach ($i = 0; $i <= @sorted; $i++) {

 chomp($i);
 $j = $i++; # Only finds 1 address beyond $i

 if ($sorted[$i] =~ /$j/) # Compare this line w/next line
 {
  next; # If it matches, skip it
 }

 else {
  print "Address = $sorted[$i] \n";
 }

}


####################

Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
[EMAIL PROTECTED]


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to