Probably something like this: open FILE, "input.txt" or die "Could not open input.txt: $!\n"; # open the input file containing the records
open OUTFILE, ">output.txt" or die "Could not open output.txt: $!\n"; #output the output file for unique recs my %addys; # a hash to store the unique recs in while( <FILE> ) { # loop through the file, store current rec in $_ my @record = split(/|/,$_); # record[0] = lastname # record[1] = firstname # record[2] = company # record[3] = email print OUTFILE $_ if !$addys{$record[3]}++; # if we have not seen the email before, then write it to the output file. } ----- Original Message ----- From: "Hughes, Andrew" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, May 10, 2002 3:14 PM Subject: Text file manipulation > I have a pipe delimited text file that I use as a mailing list I have > information in the following format: > > lastname|firstname|company|email|state|date > > I am using it as a mailing list. However, over the last half year, it has > gotten pretty big, and has some duplicates in it. For reporting sake, I > would like to delete the duplicate records based on email addresses. If you > sign up three times, I only want to keep your first record in there. > > I want this file: > > jones|Bob|Acme1|[EMAIL PROTECTED]|GA|2/25/2002 > jones|Bob|Acme1|[EMAIL PROTECTED]|GA|2/28/2002 > smith|Jan|Acme2|[EMAIL PROTECTED]|FL|3/1/2002 > johnson|Salley|Acmeshop|[EMAIL PROTECTED]|TN|4/5/2002 > > SMITH|JAN|ACME2|[EMAIL PROTECTED]|FL|5/2/2002 > > to change to this file: > > jones|Bob|Acme1|[EMAIL PROTECTED]|GA|2/25/2002 > smith|Jan|Acme2|[EMAIL PROTECTED]|FL|3/1/2002 > johnson|Salley|Acmeshop|[EMAIL PROTECTED]|TN|4/5/2002 > > Can anyone point me in the right direction? I appreciate any help. > > Thanks, > Andrew > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]