Linux HOWTOs

About | Home | Search


HOWTO: perl
Description: Practical Extraction and Report Language
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# Perl 5.10.0
# ===========
# A version-specific version of Perl is one where the paths look like this:
# /usr/lib/perl5/5.10.0
# /usr/lib/perl5/site_perl/5.10.0
# Usually the /usr/lib/perl5 directory itself only has the 5.10.0 directory
# and the site_perl directory in it (no modules).
#
# If you do NOT have a version-specific version of Perl, try something like
# this to move your soon to be replaced version of Perl's site_perl directory
# into a version-specific directory.  I haven't tried this in a long time,
# but I would imagine it should work with any prior version of Perl.  The
# example here uses version 5.8.8 (the previous version of Perl), if you use
# an older version like 5.6.1, replace 5.8.8 with your version.
#
# cp -a /usr/lib/perl5/site_perl /tmp/5.8.8
# removepkg perl
# test -d /usr/lib/perl5 && rm -r /usr/lib/perl5
# mkdir -p /usr/lib/perl5/site_perl
# mv /tmp/5.8.8 /usr/lib/perl5/site_perl/

# If you have Perl modules in some other location outside of the
# /usr/lib/perl5 tree and want to use those, add something like this:
# -Dotherlibdirs=/other/weird/location/perl5/site_perl/5.8.8
# to the ./Configure line below.  Any version specific directories under
# /usr/lib/perl5 will be used by the new Perl.

cd
test -f installed/perl-5.10.0.tar.gz && mv installed/perl-5.10.0.tar.gz .
test ! -f perl-5.10.0.tar.gz &&
 wget http://www.cpan.org/src/perl-5.10.0.tar.gz

# Verify tarball w/ md5sum:
echo "d2c39b002ebfd2c3c5dba589365c5a71  perl-5.10.0.tar.gz" | md5sum -c

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "perl-*" -exec rm -r {} \;
tar xzvf ~/perl-5.10.0.tar.gz
cd perl-5.10.0
test $UID = 0 && chown -R root:root .

# If not before you even start, while Perl is compiling you may want to open
# another console and read these:
# 'less ./README'
# 'perldoc ./INSTALL'
# 'perldoc ./README.linux'
# 'perldoc pod/perl5100delta.pod' (if this is an upgrade)

# I use gcc >= 3.2.x everywhere, it includes more -march types than earlier
# versions.  With < 3.2 I'd specify -march=i686 for a pentiumpro and up,
# with > 3.2 you can use pentiumpro, pentium2, pentium3, and so on (and AMD
# chips have types too).  See 'man gcc' for other arch types.  If you leave
# off the -Doptimize part below, the build will use -O3 by default.
#
# Below I pass -O3 and -march=pentium4 to gcc for optimization on the
# pentium4 box that I'm building Perl on right now.

# Run "./Configure -h 2>&1 | less" to see the list of options
#
# This will use all of the defaults and sparse output:
# ./Configure -des

./Configure -de -Dprefix=/usr -Dusethreads -Doptimize='-O3 -march=pentium4'
make
make test

# Become root to install it
su

# Remove Slackware package and any old perl binaries and symlinks
test -x /sbin/removepkg && /sbin/removepkg perl
test -L /usr/bin/perl && rm /usr/bin/perl
test -f /usr/bin/perl && mv -f /usr/bin/perl /usr/bin/perl.old

# Install the new version of Perl
make install
ln -sf /usr/bin/perl5.10.0 /usr/bin/perl
test ! -L /usr/local/bin/perl && ln -sf /usr/bin/perl /usr/local/bin/perl
(cd /usr/include && h2ph *.h sys/*.h)

# If your Perl is installed under prefix /usr (/usr/lib/perl5), you may want
# to create a symlink in /usr/local to point back to it for apps like Cyrus
# IMAP that install things under /usr/local/lib/perl5:
test ! -d /usr/local/lib/perl5 &&
 ln -sf /usr/lib/perl5 /usr/local/lib/perl5

# If you just upgraded a source-installed Perl, you most likely have a
# /usr/bin/perl?.?.? binary for the old version.  If you no longer need it,
# you can safely remove it now.

# perlcc is gone, remove it
# (there's a section about it in 'perldoc perl5100delta')
rm -f /usr/bin/perlcc

# If you use Perl's CPAN module, you should make sure it's configured and
# that you've got the latest version.  I usually accept the default settings
# for everything except: "Policy on building prerequisites" -> follow,
# "Parameters for the 'make install' command" -> UNINST=1.  Set this way,
# CPAN can install a module and it's dependencies automatically, as long
# as it builds and tests OK.
perl -MCPAN -e 'install Bundle::CPAN'

# Make sure your non-root user can remove the source later
chown -R $USER .
chmod -R u+w .

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/perl-*.tar.*
mv perl-5.10.0.tar.gz installed/

# If you're upgrading from an older 5.10.x version to a newer one, you
# shouldn't have to rebuild the Perl modules that you use that use C code.
# If you're upgrading from an older Perl like 5.8.8 or 5.6.1, you'll have
# to rebuild any Perl modules that include C code.  If you upgraded from
# 5.8.8 for example, try running this:
# find /usr/lib/perl5/site_perl/5.8.8 -type f -name "*.so"
# to see what some of them might be.  Some examples are:
#
# Compress::Zlib
# Digest::MD5
# Digest::SHA1
# GD
# HTML::Parser
# Term::ReadKey
# Tk
#
# And the Perl modules that come with these:
# Cyrus IMAP
# The Gimp (Slack's 'gimp' package includes modules for the version
#   of Perl that comes with Slack)
# ImageMagick
# mod_perl (Apache::*)
# Net-SNMP
# RRDtool
# SDL_perl

# If you want to clear out files and dirs from previous versions of Perl,
# take a look through /usr/lib/perl5/site_perl/?.?.? (where ?.?.? are previous
# versions of Perl).  In there are modules that were installed for the older
# versions.  You can reinstall those modules like this:
# perl -MCPAN -e 'force install Foo::Module'
# (force is not necessary if you're installing a newer version) and when
# you're done, then you can remove the directory for the older version.  If
# you specified UNINST=1 during the configuration of the CPAN module, as
# specified above, CPAN will remove the old version for you.
#
# If you plan on using multiple versions of Perl, keep any
# /usr/lib/perl5/?.?.? dirs around that you need for the old ones.

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>