Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#!/usr/local/bin/perl -w

If you are writing CGI scripts then make sure you add the -T taint option. 

Do NOT use #!/bin/env perl -T for CGI scripts, it does not work

Writing safe scripts

Run with -w and use strict to ensure Perl isn't assuming things incorrectly. Check all return values. Include the ability to turn on debugging (e.g. print different output depending on the value of my $debug). Use $debug=-1; if yu want no output except errors (e.g. for cronjobs), $debug=0 for the default when run from the command line, $debug>0 when trying to debug the program. Larger values of $debug result in more informative output. 

CGI scripts 

These run as user nobody and need to be super secure. Read the Oerl Cookbook and "Writing a Safe Secure CGI program". Always use the taint mode (-T).  

PerlTidy

To ease formatting and translations of the various coding styles available, it is recommended that the tool PerlTidy should be used to (re)format code to the format desired.

...