In one of my forms i have two email fields... One of a Referrer and other of the Referrer's Friend. Now i want to log both of these emails in a text file and also avoid any duplicate entries. Presently i am using the following sub routine to log the Referres's Email address and the same thing repeated with the names of the variables changed to log the Referrer's Friend's Email.
sub Log_Ref_Email {
open(SUB, "subscribelist.txt") || die "Cannot open file $!";
@emails=<SUB>;
close(SUB);
@email = grep{ /$in{'ref_email'}/i } @emails;
if (@email) {
} else {
open(SUB, ">>subscribelist.txt") || die "Cannot open file $!";
print SUB "$in{'ref_name'}\t$in{'ref_email'}\n";
close(SUB);
}
}
But the problem is, i want to avoid writing the same sub routine more than one time and still complete the job. The reason why i want to avoid writing the sub routine more than one time is that the next script i have to code contains 5 user input emails and i am sure there is much simpler and shorter way to do this.
Can anybody help me out with this???
Thanx.
sub Log_Ref_Email {
open(SUB, "subscribelist.txt") || die "Cannot open file $!";
@emails=<SUB>;
close(SUB);
@email = grep{ /$in{'ref_email'}/i } @emails;
if (@email) {
} else {
open(SUB, ">>subscribelist.txt") || die "Cannot open file $!";
print SUB "$in{'ref_name'}\t$in{'ref_email'}\n";
close(SUB);
}
}
But the problem is, i want to avoid writing the same sub routine more than one time and still complete the job. The reason why i want to avoid writing the sub routine more than one time is that the next script i have to code contains 5 user input emails and i am sure there is much simpler and shorter way to do this.
Can anybody help me out with this???
Thanx.