Build a Perl/CGI Voting System
By Allan Peda2005-07-05
Other possible improvements
In a nod to the need to filter incoming data, I set the variables $CGI::DISABLE_UPLOADS and $CGI::POST_MAX to very strict values. Additionally I recommend the following:
- String all incoming variables of all unexpected characters and truncate the length to a reasonable limit.
- A lot of runtime data is kept inside the script. The advantage to this practice is that there are fewer files to distribute and to set permissions for. The disadvantage is that users may not want to edit code, and the code becomes less clear. A possible compromise may be to take advantage of kludges such as the
DATApseudo-file handle to tuck data at the end of a script. - File locking is a very tricky issue and race conditions abound. It seemed that for every guideline I found spelling out the correct way to lock files, a subsequent correction was posted. I tried to minimize the time files were open and leverage the locking mechanism provided for the
MLDBMmodule. - Perl modules are not put in their own path away from the CGI, so they could theoretically be executed from the cgi-bin directory. It is recommended that these modules not be set as executable.
- PHP is practically ubiquitous on Linux platforms, so I would consider porting this script in PHP if the need to reimplement it arose. However, I am not sure there is a PHP equivalent to the
MLDBMmodule. - The layout of the voting form is considered unfair by some since it presents the first candidate as a default.
- I did not use perldoc. I should.
First published by IBM DeveloperWorks
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "Build a Perl/CGI Voting System"
You must be logged in to post a comment.
Link to This Tutorial Page!

