P
perl
Cheers and thanks in advance for you help. I have a routine intended
to purge duplicate emails from a list. The code below is just. I'm
sure it needs to be in a %hash but I'm lost. Any help is appreciated.
sub purge
{
open (LIST, "$list") or error("$list email purge 1");
while (my $line = <LIST>)
{
@emails = split(/\r?\n|\r/, $line);
@emails2 = @emails;
}
close (LIST);
foreach $email(@emails)
{
foreach $email2(@emails2)
{
if($email ne $email2)
{ $newemail .="$email\n"; }
else{ $purgecnt++; }
}
}
open (LIST, ">$list") or error("$list email purge 2");
flock(LIST, LOCK_EX);
print LIST $newemail;
close (LIST);
&success("$list has been purged of $purgecnt duplicates");
}
to purge duplicate emails from a list. The code below is just. I'm
sure it needs to be in a %hash but I'm lost. Any help is appreciated.
sub purge
{
open (LIST, "$list") or error("$list email purge 1");
while (my $line = <LIST>)
{
@emails = split(/\r?\n|\r/, $line);
@emails2 = @emails;
}
close (LIST);
foreach $email(@emails)
{
foreach $email2(@emails2)
{
if($email ne $email2)
{ $newemail .="$email\n"; }
else{ $purgecnt++; }
}
}
open (LIST, ">$list") or error("$list email purge 2");
flock(LIST, LOCK_EX);
print LIST $newemail;
close (LIST);
&success("$list has been purged of $purgecnt duplicates");
}