CS4173 > Materials > sysdocs > CGI > in Perl
When programming with Perl 5 you should use the built-in help to detect errors before they become serious problems, and to explain them when they do occur:
-w
switch when invoking perl, for example:
#!/opt/bin/perl -Twas the very first line of your program.
-T
switch is discussed below in the section
specifically about CGI programming.)strict
pragma at the start of the program
(before any other code): use strict;
use diagnostics;
when programming CGI programs with Perl 5 you should take these additional steps also:
-T
switch before any other switches when
invoking perl, for example: #!/opt/bin/perl -Twas the very first line of your program.
-T
switch turns on taint checking which is needed
for form
processing.
(The -w
switch is discussed above, in the section
about programming in Perl in general.)
$| = 1;or
use English; $OUTPUT_AUTOFLUSH = 1;
if you use the CGI.pm module (which I recommend) then
use CGI qw(:standard :Carp -debug);and
use CGI::Carp 'fatalsToBrowser';
I also recommend Tom Christiansen's list of common CGI mistakes made by Perl programmers.
See the the advice2.pl script, in the examples subsection, as an example of a simple working CGI program.