From DreamHost
Jump to: navigation, search

Perl is a programming language used widely in the UNIX/Linux world to write everything from quick and dirty scripts to powerful, broad-featured programs.


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.


Dreamhost's Perl version

Dreamhost uses Perl version 5.14.2. As with Python and PHP, you can build another version in your home directory if necessary. Just remember that these count against your total server storage. Most Perl programs should work fine with the installed version.

Upgrading Perl

Perl 5.10.0 and all versions prior to 5.8.9 will currently not build from source on a dreamhost user account because /home/ is not readable. This breaks the pure-perl implementation of cwd it uses while building itself. In 5.8.9 and 5.10.1 this problem has been fixed. If you want to install one of previous versions, just copy the lib/ from a 5.8.9/5.10.1 source directory into the 5.8.8/5.10.0.

Perl versions 5.8.9, 5.10.1, 5.12.0 and higher work just fine from the box.

To match the system Perl, and take advantage of its installed libraries, configure your perl like so:

sh Configure -Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux \
   -Dprefix=~ -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib \
   -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dvendorprefix=/usr -Uinstallusrbinperl -des

You may need to disable the 'vendorlib', 'vendorarch' and 'vendorprefix' arguments to Configure as shared library symbols change from version to version; Perl 5.16 appears to require this.

Using Perl Modules

Please see the Perl modules wiki page for details on using existing and installing new perl modules.

Perl debugging

Why Perl CGIs can fail mysteriously

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 the KB article for further detail.