CGI/Perl Threading Problems!!
I have encountered a very interesting browser-specific problem with CGI/Perl.
My script is well over a hundred lines, but I will outline its general structure as follows:
# if the target file exists, abort
if(-e "newfile.html")
{
&Error("newfile already exists!")
}
#else open a new file for write access
if(open (FILEHANDLE, ">newfile.html") == 0)
{
&Error("Couldn't open newfile.html");
}
# print a bunch of stuff to the file
print FILEHANDLE ....
print FILEHANDLE ....
# print a message to stdout to indicate #success
Here's the oddity. This works well in Netscape. I get the success message on my screen. HOWEVER, In IE I ALWAYS GET THE NEWFILE ALREADY EXISTS ERROR!
I erase the file, run the CGI script, and escape with the "file exists" error. I then look on the server, and the file has actually been successfully created. So it looks as if the CGI server spawns a slow thread that checks for the file existence. In the meantime, a fast thread performs the subsequent commands and creates the file. Then all of a sudden the slow thread says, "I can't go on. This file already exists!" Does Perl use threading like this? Why in the world would the CGI server run the script differently for different browsers!?
I'd love to hear any ideas or similar encounters.