Red Antigua Logo
Yet another piece of web.
Search this site (by Google)
Tools    (top)
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
MSYS2 - UNIX environment for MS Windows 32/64 bits
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Perl modules - install and use
Perl modules - install and use
Before you install a module, be sure that it isn't installed already:
perldoc perllocal
The recommended way to install Perl modules is to invoke the CPAN shell.
First time running the shell, you have to setup some parameters.
Read about all the details at http://search.cpan.org/perldoc?CPAN.
Normally it is sufficient to just type:
install Some::Module
and CPAN will take care of the rest (download, configure, install).
Sometimes, anyhow, you want to customize the installation.
You can find an example here, installing the DBD::mysql module.

If you still insist to install modules manually, here is how to do it:
Download your favorite module from CPAN and install it:
# gunzip -c Some-Module-X.X.tar.gz | tar -xf -
# cd Some-Module-X.X
# perl Makefile.PL
# make
# make test
# make install

Use the module from your Perl script:
#!/usr/bin/perl
use strict;
use Some::Module;
Install it in your own path /home/redantig/perl (if you don't have root access, for example - note that this can be done from within the CPAN shell as well):
# gunzip -c Some-Module-X.X.tar.gz | tar -xf -
# cd Some-Module-X.X
# perl Makefile.PL LIB=/home/redantig/perl PREFIX=/home/redantig/perl
# make
# make test
# make install
If you need to use module dependencies already installed in the same path (i.e. /home/redantig/perl), you have to use the perl -I flag (to modify @INC).
(See other solutions in the Perl Cookbook, p. 413.)
# perl Makefile.PL -I/home/redantig/perl LIB=/home/redantig/perl PREFIX=/home/redantig/perl
Some times (depending on the Perl version) the -I flag doesn't work, so you have to set the PERL5LIB environment variable to install the modules correctly.
Heres a variant to be sure that Makefile.PL find your modules:
# export PERL5LIB=/home/redantig/perl
# perl Makefile.PL -I/home/redantig/perl LIB=/home/redantig/perl PREFIX=/home/redantig/perl
Use the module in your path from your Perl script:
#!/usr/bin/perl
use strict;
use lib qw(/home/redantig/perl);
use Some::Module;
Instead of using the use lib qw(/home/redantig/perl) pragma in your script, you can specify the library path from the command line:
# PERL5LIB=/home/redantig/perl ./yourscript.pl
or
# PERL5LIB=/home/redantig/perl perl -w yourscript.pl

Don't forget to check the documentation that comes with the module:

# perldoc Some::Module

The CPAN FAQ has a lot of more information about Perl modules.

Last modified: Tue Sep 6 11:25:02 EDT 2016