From DreamHost
Jump to: navigation, search


Perl is a programming language used widely in the UNIX/Linux world to write everything from quick scripts to powerful, broad-featured programs. The following is a description from the perlintro man page:

      What is Perl?
      Perl is a general-purpose programming language originally developed for
      text manipulation and now used for a wide range of tasks including sys-
      tem administration, web development, network programming, GUI develop-
      ment, and more.
      The language is intended to be practical (easy to use, efficient, com-
      plete) rather than beautiful (tiny, elegant, minimal). Its major fea-
      tures are that it's easy to use, supports both procedural and object-
      oriented (OO) programming, has powerful built-in support for text pro-
      cessing, and has one of the world's most impressive collections of
      third-party modules.
      Different definitions of Perl are given in perl, perlfaq1 and no doubt
      other places. From this we can determine that Perl is different things
      to different people, but that lots of people think it's at least worth
      writing about.


Perl was created in the mid-1980s by Larry Wall. Its original intent was to fill in the gap between so-called "low-level" languages like C and C++, and the higher level scripting languages like awk, sed, and shell scripts. It has evolved considerably since then, becoming the de facto language of choice for many *nix system administrators and power users. It has found broad appeal on the internet (a mostly *nix based network) as the background code behind many sites on the World Wide Web. A notable example is Slashdot.

Perl on DreamHost

Path to the Perl interpreter

The path to Perl on DreamHost's servers is below. This path is standard on *nix based systems and most scripts should not need to be modified.


mod_perl is currently not supported at DreamHost. You must use FastCGI instead.

DreamHost's Perl version

As of June 2015, DreamHost uses Perl version 5.14.2. As with Python and PHP, you can build another version in your home directory if necessary. However, most Perl programs should work fine with the installed version.

Using Perl Modules

DreamHost has nearly all the common Perl modules installed, as well as many uncommon ones.

To check whether a Perl module is installed on DreamHost's servers, first log into your shell account, then type the following:

perl -MThe::Module::Name -e0

Where The::Module::Name is, obviously enough, the name of the Perl module you are looking for.

Dh-kb-note-icon.fw.png Note: The command outputs nothing when the module is found. If it's not found, an error is thrown.

Installing custom modules

You can install your own modules in your home directory directly. Follow these DreamHost specific instructions for installing CPAN modules.

Perl FastCGI

The perl FCGI module is installed by default on DreamHost servers.

To test that FastCGI is configured and working properly, try this simple 'Hello World' program. Paste this text into a file with the ending .fcgi.


use lib qw( /home/myhome/lib/perl/5.8.4 );
use FCGI;
use Socket qw( :crlf ); # server agnostic line endings in $CRLF

my $counter = 0;
while ( FCGI::accept() >= 0 ) {

        "Content-Type: text/plain",
        "Hello World, in Perl FastCGI!",
        "I am process $$.",
        "I have served $counter request(s).",

The $CRLF is a server neutral line ending equivalent to "\015\012." It will always work. "\n" or even "\r\n" sometimes will not.

If you change the extension of this script to .pl or .cgi so it's handled by regular CGI, you'll notice that the PID is different on every request, and the request counter stays at 1.


DreamHost runs suexec. suexec requires that all cgi scripts and the directories in which they reside not be writable by anyone but the owner (ie, user). This means that you have to change the permissions of the script as below using chmod:

chmod -R 755 perldir

Where perldir is the directory in which your perl CGI resides.

See also