I have 100 questions to place in forms, I need to know if there is a CGI script that can process 20 questions per page then submit, then get 20 more and so on till the final 20, then it will validate after each 20 and submit all 100. Then send a e-mail to our server with the responses we are looking for..
Paco Zarabozo here's a quick way to do what you need...
Always use strict.
Always use warnings.
Always enable taint checks.
What if an answer contains a vertical bar?
What if an answer contains quotes?
File handles should be uppercase. unless condition is meant to be a more readable form of if not condition. Using unless not condition defeats the purpose.
Originally posted by jeffmott Always use strict. <- not absolutely necessary
Always use warnings. <- useful, yet not absolutely necessary
Always enable taint checks. <- not absolutely necessary
What if an answer contains a vertical bar? <- I forgot. Corrected.
What if an answer contains quotes? <- I forgot. Corrected.
File handles should be uppercase. <- why? unless condition is meant to be a more readable form of if not condition. Using unless not condition defeats the purpose. <- So, if (!$var) is wrong too?
Sorry for the forgotten parts. I'm used to my form module, in which i replace all those characters. I just forgot about it. Sorry.
Last edited by Paco Zarabozo; 02-08-2003 at 03:23 PM.
strict, warnings, and taint are not required for the script's compilation but are strongly recommended to the point of almost being a rule. And their use generally results in much better programs by enforcing good programming practices.
File handles should be uppercase because if it is all lowercase it may clash with a future reserved word. This is a potential bug. One which you would have been warned about had you enabled warnings.
I didn't say if (!$var) was wrong, I said it defeats the purpose of having a more readable alternative.
I have bad habits with perl. I consider i have done very good and complex programs in perl, but the fact is that i can write things in a bad way becuase i learned by myself, translating my knowledge about other languages. You can go far, but if you don't have a good teacher, or a really well documented tutorial, you can grow with bad habits.
So, you'd recommend to always start perl with #!perl -Tw, in any script?
Paco Zarabozo So, you'd recommend to always start perl with #!perl -Tw, in any script?
Yes, and so do the creators of Perl. Warnings is recommended for all scripts, and taint mode is recommended for every script whose action is dependant on external input (which includes virtually all CGI scripts).
What about -c? Does it work in web scripts?
It technically would do what it's supposed to, but you won't see the results since it doesn't return with an HTTP header.