ActivePerl already includes many modules for common tasks like accessing databases, using network services, parsing XML files, compressing and decompressing data, or creating GUI applications.
Sooner or later you will want to use additional modules from CPAN that are not already included. You can either download pre-compiled binaries with the Perl Package Manager (PPM) or you can build and install the modules yourself with the regular Perl tools, like the CPAN shell. All it takes is a simple command like this:
ppm install Crypt::Blowfish
or:
cpan Crypt::Blowfish
The following information is accurate for ActivePerl 5.8.9.827, 5.10.1.1007 and 5.12.2.1202. For earlier versions details may be different.
Using the Perl Package Manager
ActiveState maintains repositories of precompiled CPAN packages that can be installed with either the PPM command-line client, or the PPM GUI application. To install the DBD-mysql database driver all you have to do is run the ppm install command:
Alternatively you can run ppm without any parameters to invoke the GUI, search for DBD-mysql, select the DBD-mysql package, and perform the installation:
ActiveState downloads all new packages from CPAN once a day and tries to build them for each supported platform. The generated binaries will be added to the PPM repositories if:
- All required prerequisite modules are available.
- The build is successful.
- The module passes all of its own regression tests.
Using additional repositories
Even modules that failed to build on the automated ActiveState build system may still be installable via PPM: There are several other people maintaining additional PPM repositories, and often they go and spend the required manual effort to get these modules building.
PPM includes a list of public repositories, including the architectures they support. You can display the available repositories for your platform with the `ppm repo suggest` command and then add them to your PPM configuration using their shortcut names:
ppm repo suggest ppm repo add uwinnipeg
In the PPM GUI these additional repositories are included in the Preferences dialog in the Suggested dropdown list:
Note that currently only the Windows platform has additional third-party PPM repositories.
Using PPM with a proxy server
PPM uses the LWP module to access the ActiveState package repository. If internet access must go through a proxy server, then the http_proxy environment variable must be set to tell LWP how to get a connection. The syntax for setting the variable depends on the shell; for the Unix bash shell it looks like this:
export http_proxy=http://proxy.company.com
And for cmd.exe on Windows it looks like this:
set http_proxy=http://user:passwd@proxy.company.com:8008
A common error is to leave out the protocol prefix ("http://" or "https://") from the variable setting, in which case it will not work at all.
Many places on the net explain that the environment variables http_proxy_user and http_prox_pass need to be set. This information was true for the old PPM3 client and is no longer correct. Only the standard http_proxy variable is used.
The ppm log command is a handy debugging tool to display the last couple of minutes from the PPM log file in case the connection to the repo still fails after setting the http_proxy variable:
ppm log 5
Building modules locally
It is always possible to attempt to build a module locally if it cannot be found in the PPM repositories. This requires both a make utility and often also a C compiler. On Linux the GCC compiler and the GNU make utility are typically already installed.
On Mac OS X both GCC and GNU make are part of Apple's Xcode developer tools, which can be installed from the OS X installation DVD, or downloaded from the Apple Developer Tools website.
Installing a make utility and C compiler on 32-bit Windows
For 32-bit Windows the recommended C compiler is either Visual C++ 6.0 with the bundled nmake utility, or the MinGW version of GCC for Windows together with the dmake utility.
Later versions of Visual C++ will work as well. They will however link against a different C runtime library, which in rare cases can cause some compatibility issues.
The CPAN shell will automatically download and install MinGW and dmake on first use if you don't have Visual C++ or MinGW already installed and on your PATH:
If you want to use the MinGW compiler to build modules manually from the commandline, then you can install MinGW yourself using PPM:
ppm install MinGW perl Makefile.PL dmake dmake test dmake install
Tips:
- MinGW and dmake are being installed into C:\Perl\site\bin. Make sure this directory is on your PATH (done by default by the ActivePerl installer).
- You must use nmake.exe with the Microsoft compiler, or dmake.exe with MinGW. Using dmake.exe with Visual C++, or nmake.exe with GCC will not work.
Installing a make utility and C compiler on 64-bit Windows
For 64-bit Perl on 64-bit Windows currently the only supported compiler is the Visual C++ compiler included in the Windows Server 2003 SP1 Platform SDK (aka the April 2005 edition).
Use the SetEnv.cmd script to set the PATH, LIB, and INCLUDE environment variables to the correct value for building ActivePerl extensions with this command:
"C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd" /XP64 /RETAIL
Summary
The easiest way to install additional modules into ActivePerl is by using PPM, the Perl Package Manager. But on each platform there is also a free native C compiler available that can be used to build modules locally if that turns out to be necessary.
Trackback URL for this post:
Comments
Under Win7 x64 (but I assume it is similar under x86), you can install Microsoft Windows SDK for Windows 7 and .NET Framework 4 and register environnement variables with
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /x64 /win7
(change x64 with x86 if you are in 32bits)
if all is OK, you can run cpan and install all modules that you want.
This is extremely useful and well presented but I came across the following problem: I tried to install PadWalker 1.92 (to enable Perl debug under epic) and the PPM GUI gave me this:
Installing package ...
Downloading PadWalker-1.92 ... done
Unpacking PadWalker-1.92 ... failed
ERROR: Can't extract files from C:\DOCUME~1\PEPONI~1.GEO\LOCALS~1\Temp\ppm-gm0YMJ/PadWalker-1.92.tgz
I also downloaded the tgz file and WinRAR could not unpack it either, so there is something wrong with it. I then downloaded PadWalker-1.91.tgz which WinRAR *was* able to unpack, but how do I tell PPM to use that version? Can I use command PPM with this specific file? I tried it and it complained that it could not find it on my C: drive, even with a full path.
Can somebody provide a suggestion?
Many thanks!
Gigi
Can someone explain how I can use PPM without an internet connection? I need to add the common DBD-mysql module to my ActiveState Perl installation.
Does ppm allow a "local" option, if I have already downloaded the module from CPAN? Do I need to extract/untar the module first?
I am working on an airgapped intranet system, but I can move files to the network via CDs. Quaint, huh?
Windows users (I run W7 - 64'b) can try the Eclipse IDE instead of VB 2010. I run Eclipse for Android and Java development and came across this.
http://www.epic-ide.org/index.php
Epic is the Perl plugin for Eclipse. Right now I'm trying to get the interpreter PadWalker to work and was wondering if this site knew of a solution.
This is a bit off topic. Try starting a thread for this in the ActivePerl forum:
http://community.activestate.com/forums/activeperl-support
As for Epic, if you ever get frustrated with it, give Komodo IDE a try instead :)
http://www.activestate.com/komodo-ide
Hi,
I have a query related to perl package manager.
I have installed active perl 5.12.02 and after installation if i am trying to start perl package manager by typing ppm on cmd prompt, it opens the package manger and then it hangs
showing the status
"Synchronozing database".Downloading activestate package repository packlist.
my local is not having an internet connection.
Please suggest wat cud be the problem and how it can be solved.
Thanks