Here's the latest revision, 
I don't know why it was not working earlier 
when emailLog = 'logs/email_log';
was out of the sub block. 
This script is contained in one file, with on 'use' or 'require'
statements.

The next revision I see is to move the regrex up to top of the sub
where the append takes place. Which leads to the following question,
am I to doing to many disk reades/writes, is there more efficient way 
of accomplishing what I have below:   


# Append email log and filter out duplicates  
  &addEmail;
 

sub addEmail{
my $emailLog = 'logs/email_log';

# append new email
open(EL,">>$emailLog") ||  &errorLog( "Read in, Could not find $emailLog, $!");
print EL "$Config{'email'} ($Config{'name'}),\n";
close(EL);

open(EL,"$emailLog") ||  &errorLog( "Read in, Could not find $emailLog, $!");
my @lines = <EL>;
close(EL);

rename("$emailLog","$emailLog.old");

open(EL,">$emailLog.tmp") ||  &errorLog( "Write file, could not find $emailLog, $!");

my %seen;

@lines = sort @lines;
 foreach(@lines){
    next if /test/; 
    $_ =~ s/^\s+(.*)\s+$/\1,/; 
   print EL unless $seen{$_}++;
 }

close(EL);

rename("$emailLog.tmp", "$emailLog");

}

sub errorLog{
open(ER,'>>logs/error_log') || die "could not find error_log, $!";
$errorMssg = shift;                                                                    
                                                                 
print ER "$errorMssg\n";
close(ER);
}
--------------------------------------------
Looking for Web Talent, You found it!
portfolio: www.coraconnection.com/web/
email: [EMAIL PROTECTED]
tel/fax: (860) 231-9988
--------------------------------------------

Reply via email to