Knowledge Base

Perl script basics

This article provides essential information about running Perl scripts on A2 Hosting servers.

What permissions do I need to set for my Perl script files?

The correct permissions for Perl script files depends on the script's particular function:

  • For Perl script files that are publicly accessible through the web, you should set the file permissions to 755 (read, write, and execute permissions for the user, and read and execute permissions for the group and world.) You do not need to give the world write permissions to the Perl script.
  • For Perl script files that you only run on the command line, you should set the file permissions to 700 (read, write, and execute permissions for the user, and no permissions for the group and world.)
A Perl script may need to open a file for write access. For example, guestbooks and bulletin boards often must write data to a particular file. Files that must be writable by Perl scripts can use the default file permissions of 644 (read and write permissions for the user, and read permissions for the group and world).

What file extensions can I use for my Perl script files?

Perl script files can have a .pl or .cgi extension. However, like file permissions, the file extension depends on the script's particular function:

  • Perl script files that generate web output accessible to the public should use the .cgi extension.
  • Perl script files that you only run from the command line, and script files which do not generate web output, should use the .pl extension.

What version of Perl is installed on A2 Hosting's servers?

A2 Hosting's servers currently use Perl version 5.10.

To determine the Perl version from the command line, you can type the following command:

perl -v

What is the path to the Perl executable?

The absolute path to the Perl executable on A2 Hosting's servers is /usr/bin/perl. The /usr/bin directory is in the default path, however, so generally you do not need to include the full path when you run Perl scripts from the command line. Just type the following command, replacing filename with the name of your script file:

perl filename

What is the correct FTP transfer mode for Perl scripts?

When you use FTP to upload Perl scripts to your site, always use ASCII mode. If you upload scripts in binary mode, they do not work and you receive an “Internal Server Error: Premature End of Script Headers” message (500 Internal Server Error) when you view the page.

More Information

To view the official online Perl documentation, please visit http://www.perl.org/docs.html.