perl <t...@asgweb.net> wrote:
> Cheers and thanks in advance for you help. I have a routine intended
> to purge duplicate emails from a list. The code below is not working.
> I remember seeing something like... foreach $email(@emails, @emails2))
> { etc ... but I'm lost. Any help is appreciated.

This is discussed in length in the Perl FAQ ("perldoc -q intersection").

The short answer is to map your array onto a hash:

my %seen;

foreach my $email (@emails, @emails2)){
  $seen{ $email }++;
}

# The list produced by "keys %seen" has only unique addresses.

print "unique addresses: ", join(',', keys %seen );

HTH,
Thomas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to