John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

I've always used Windows and installed ActiveState Perl.

Now I'm learning LAMP and setting up a Debian server. It comes with Perl 5.8.8. Is there a Debian APT made for the current Perl? Or what is the "right" way to upgrade it for Debian?

—John

Replies are listed 'Best First'.
Re: installing Perl 5.10 on Debian
by Corion (Patriarch) on Jun 11, 2008 at 08:15 UTC

    Do not "upgrade" your system Perl. It belongs to the system and many system tools rely on it. You will break, for instance, apt-get by "upgrading" your system Perl to Perl 5.10, if you don't take speical care.

    For your personal needs/applications, I recommend compiling your own version of Perl, and configuring it to use /opt/perl as its base directory. I keep various versions of Perl there. See the README file of the Perl distribution for how to do a local installation of Perl. The incantation there is all you nee.

    I created a perl usergroup and added my user into it. That usergroup has all rights to /opt/perl and thus I can install new modules via CPAN there without needing to switch to root.

    There is a downside to this approach - you can't use the Debian packaging environment anymore. But if you need stuff outside of Debian, it's best to avoid the Debian packaging for that. All OS packaging mechanisms are all-or-nothing in my opinion - either you exclusively use them or it's better to avoid them alltogether. Personally, I install the "third party" libraries like libxml2 etc. through the Debian mechanism, but compile my modules for my 5.10 myself using cpan. I also install the Perl libraries for the stock Perl, but only through the Debian mechanism.

      Hmm, with all the testing I would think that 5.10 would not break anything!

      It looks like ActiveState's deb package will install under /opt. So, I guess I control which Perl gets used via the PATH variable? I'm specifically interested in mod_perl and CGI under Apache.

      —John

        I'm not sure what you mean by "With all the testing". If (for example) the Debian stock perl comes with some XS extensions, the new Perl 5.10 won't pick up these, now matter how much testing. Likewise, custom patches that Debian applies to Perl for magic locations etc.

        If you want to use a Perl version for mod_perl, you need to compile mod_perl with/for the appropriate version. You should be expicit about which Perl your scripts use with the hashbang line and by using absolute paths.</c>

Re: installing Perl 5.10 on Debian
by andreas1234567 (Vicar) on Jun 11, 2008 at 08:19 UTC
    You can upgrade to Debian unstable or testing:
    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re: installing Perl 5.10 on Debian
by Anonymous Monk on Jun 11, 2008 at 08:03 UTC
Re: installing Perl 5.10 on Debian
by rudder (Scribe) on Jun 13, 2008 at 02:48 UTC

    * Keep your own Perl (the one you use for your own projects) separate from the system Perl (the one Debian uses internally for its own purposes).

    * Do not replace /usr/bin/perl with your own Perl. Your own Perl should be in /opt or ~/opt.

    * Install your Perl into its own tree (ex. /opt/perl-5.10.0). From wherever your Perl source is located, you'll configure with something like ./Configure -Dprefix=/opt/perl-5.10.0. After installation, create a symlink next to your Perl dir named "perl" (ex. cd /opt; ln -s perl-5.10.0 perl).

    * You probably want to set your own user's PATH to find your Perl (ex. /opt/perl/bin/perl) before the system's Perl -- but don't do that for the root user.

    * You might now start all your scripts with the shebang line: #!/usr/bin/env perl, which tells it to find whichever Perl is first in your PATH.

    * Update and install modules for the system Perl using only apt-get (or the newer aptitude). Never use cpanp with the system Perl.

    * Install modules for your own Perl using only cpanp. Apt, of course, knows nothing of your own Perl -- nor should it.

      * Do not replace /usr/bin/perl with your own Perl. Your own Perl should be in /opt or ~/opt.
      Myself, I would put it somewhere under /usr/local, which strikes me as much more standard than "/opt".

Re: installing Perl 5.10 on Debian
by waba (Monk) on Jun 12, 2008 at 17:34 UTC

    Or you can pull in some packages only (perl, in this case) from newer Debian versions.

    Notes:

    • Using aptitude rather than the plain apt-get shown in the link above seems like a better idea (improved dependencies, conflicts, etc. handling).
    • While I often use this trick on computers I manage, I've never tried it for perl. It's possible that it depends on too many packages to work correctly (ie. depends on half of testing, in which case you may as well upgrade completely).

    Not directly relevant to your question, but if you stick to a Debian perl, you can also use the excellent dh-make-perl tool. It allows to build Debian packages directly from the CPAN. They integrate well with the system and can be managed using standard tools (dpkg, apt-get, aptitude, ...):

    dh-make-perl --build --cpan Some::Module \ && sudo dpkg -i libsome-module-perl*.deb