I have searched tutorials, etc., on the subject of using flock but it seems like nothing gives a straight answer. I have a script for a guestbook which will allow users to upload photos. Everything goes to a MySQL database with the exception of the image which will go into an html directory. This is the part for uploading the photos:
my $upload_filehandle = $query->upload("photo");

open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!"; 
binmode UPLOADFILE; 

while ( <$upload_filehandle> ) 
{ 
 print UPLOADFILE; 
} 

close UPLOADFILE; 
}

How do I install a lock to prevent corrupt data from more than one submission at a time?
While I'm asking question, how important is use stric
I removed it so that I could call the errors from a separate page for the purpose of translation into different languages(the guestbook is only a part of the overall script). I'm finding many things confusing using use CGI as I was taught using the cgi-lib.pl method but have seen to many places that it is not the way to go. Also-to make the script work I had to remove the t switch for tainted input. It made the script not work at all. Am I really screwing by removing that? I've been looking for answers for about a week with one of the slowest connections in the world---any help would be appreciated. Thanx

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Using "strict" is important , especially for new perl coders, but it is not necessary to use it. But you will see that 99% of all perl scripts use "strict" and most use "warnings". The -T switch (not -t) is also important for a CGI script. It is there to help prevent something dangerous from occuring, like using user input to open a file.

To lock a file you use the flock() function:

http://perldoc.perl.org/functions/flock.html

Install the newest confirmed service packs for your edition. You can install it easilt as I think so. Although, I do not think that why flock does not work for you. In fact I am happy with it.

This article has been dead for over six months. Start a new discussion instead.