I've a CGI script that takes an email address and a boolean and depending on the boolean adds/removes the address from a mailing list. The mailing list is a flat text file with 1 address per line.
When an item is removed, I read every entry except ones that match the address to remove and write them to a temp file, then rename the temp file. This gets rid of the addresses that I don't want.
But, what happens if 2 people run the program, and one person's overlapps the second. How do I do a waiting thing to set the program to wait until no other processes are using the file? Any ideas? Is there a better way to do this? How exactly is file I/O done in perl (as far as it affects this problem?).
Thanks
MWB.
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
When an item is removed, I read every entry except ones that match the address to remove and write them to a temp file, then rename the temp file. This gets rid of the addresses that I don't want.
But, what happens if 2 people run the program, and one person's overlapps the second. How do I do a waiting thing to set the program to wait until no other processes are using the file? Any ideas? Is there a better way to do this? How exactly is file I/O done in perl (as far as it affects this problem?).
Thanks
MWB.
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.