Vivek Khera <[EMAIL PROTECTED]> writes:
> >>>>> "RE" == Rob Egan <[EMAIL PROTECTED]> writes:
> 
> RE> CGI scripts to behave in mod_perl. All it does is capture e-mail addresses,
> RE> and place them in a text file so we can gather them up later and drop them
> RE> into a database. If you run the script as a regular CGI (without mod_perl
> RE> enabled) it works great. But on the mod_perl enabled server, the script
> RE> throws garbage into the file and overwrites previous entries if a user
> RE> submits more than one e-mail address in a single session (i.e. they enter
> 
> It has nothing to do with the person quitting the browser.  It has to
> do with your script using global variables.  Turn on "use strict" and
> perl warnings and see what your error log says.
> 
> Then go to the mod perl guide and search for "sticky variables".

But since they are all global (no use of my), they won't be sticky.

There is plenty wrong with the script, although I can't specifically
correlate the symptoms with the mistakes.  Sometimes the file is
referred to as $results_file and in other places by its literal name.
The 'if (-e $results_file) open ">..." else open ">>..."' code is
unnecessary and will break if 2 processes hit the first if
concurrently.  Just open it in append mode.  If it isn't there it will
be created.  If you don't have write permission the open will fail.
The locking is classically broken "# Unlock before you close" No!
Wrong!.  Just close the file.  That has the desired side-effects of
first flushing the buffered data and then unlocking the file.

-- 
Frank Cringle,      [EMAIL PROTECTED]
voice: (+49 2304) 467101; fax: 943357

Reply via email to