[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] removing duplicate records from file



"J. Linder" <jann@jann.com> wrote:
>how do i scan the file, read in the records and discard the duplicates.

read in file, chomp each line, split on |, build a hash with the email
address as the key, as in $foo{$email} = $name. This way, the last $name
will overwrite previous values for the same $email. If this is
unacceptable, just test for whatever condition you like before assigning.
e.g.

# if already assigned, don't overwrite.
if (!$foo{$email}) {
	$foo{$email} = $name;
}

--
Neil Kandalgaonkar    njk@odyssee.net    http://www.odyssee.net/~njk/



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch