Do not use your home web space for files used by your script. When you have moved on to other pastures and your account is closed then the script will fail.

When open'ing a file use the three argument form of open (open FILEHANDLE, MODE, LEFT; ) when possible. This will prevent the redirect mode symbol(s) from being misinterpreted as part of the filename. This can be especially important when a user might provide the filename (e.g. in CGI script) and maliciously or unintentionally include a redirct symbol(s) in the filename. 

Also always follow the open (or close) with an or die (by the way not a ||) to catch unexpected file/disk system errors.

To make a file accessible to others in the group or to a cronjob use umask(0002);

  • No labels