Syntactic Confectionery Delight | |
PerlMonks |
Re: Writing a perl based web poll.by Tanalis (Curate) |
on Jul 15, 2003 at 09:46 UTC ( [id://274332]=note: print w/replies, xml ) | Need Help?? |
As has already been pointed out by Skeeve, you're not reading in the data there before you start incrementing the results.
It's also a very good idea to lock the results file before you write to it - especially with web applications - otherwise you could find that the file gets clobbered and you lose the data in it. I've always done this using Fcntl's flock method, which can be set to only allow one process read/write access to a file at a time. It seems most effective (from experience) if you use flock on a lock file, and lock that, rather than the results file directly before you write any data. For example: I'm sure this is documented somewhere in a much better way than I can explain it, and with the reasons behind the use of the external lock file rather than direct locking, but I can't find it at the minute. I'll keep looking .. *grin* Hope that helps. -- Foxcub
In Section
Seekers of Perl Wisdom
|
|