I am trying to use the following piece of code for subscribers to
unsubscribe from my mailing list. The problem is that when the user clicks
submit the file gets read into memory. If I open the file as open
(DELETEFILE, ">>" . etc., the list gets overwritten entirely with nothing.
It appears that nothing get saved in memory because I'll try to output
@emailfile using print @emailfile; to test what is being saved and it is
blank as well.
If I open the file as open (DELETEFILE, "" . etc, the info gets stored into
memory because I can print it out using print @emailfile which gives me the
entire file. Then, when I try to print back to the file, it is the entire
array. Nothing has changed. Can anyone see what I am doing wrong or offer
a better approach?
On a side note, I am doing all of the email validating and taint checking in
a previous subroutine.
Thanks,
Andrew
sub deleteFromSubscribeList {
open (DELETEFILE, ">>" . $mailingListPath . $mailingListName) or die "cannot
open file for appending: $!";
flock (DELETEFILE, 2) or die "cannot lock file exclusively: $!";
my @emailfile = ; #
seek (DELETEFILE, 0, 0);#
truncate (DELETEFILE, 0); #
print @emailfile;
foreach my $line (@emailfile)
{
if ($line !~ /^\Q$deleteEmail/o)
{
print DELETEFILE $line; #
}
}
close (DELETEFILE) or die "cannot close message file: $!";
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]