Perl Installation Hints and Tips
MacPorts
If you're already using MacPorts, it's probably easiest to create a
localised Portfile using cpan2port
.
See https://trac.macports.org/wiki/howto/cpan2port
-- Frank Dean - 06 Jun 2024
Installing Without Using CPAN to Manage Modules.
You may want to do this if you are using a package management system that manages the Perl environment but doesn't contain packages you otherwise need to install. By installing in another location, you can avoid polluting the managed Perl packages.
Download the latest CPAN package from http://www.cpan.org/.
- Install the CPAN bundle using the following general instructions.
Instructions for installing CPAN packages should be available at https://metacpan.org/dist/perl/view/pod/perlmodinstall.pod, but basically is as follows:
- su to root
- untar the downloaded package to a temporary working area
- Change to the newly created package directory
- perl Makefile/PL
- or (To stop prompts during the installation process...)
- perl Makefile/PL -n
- make
- make test
- make install
If the tests fail, it's probably because there's a package dependency. To find out what dependencies there are, refer to the README for the package.
- less ~/tmp/build/PACKAGE_NAME/README
- less ~/.cpan/build/PACKAGE_NAME/README
Once you've got the CPAN module installed, you can install other modules directly from CPAN with:
- perl -MCPAN -e 'install "BUNDLE::NAME"'
See above for dealing with any failed tests.
To quickly check whether a package is already installed:
- pearl -MMyPerl -e 1
If no error message, then it's installed.
See also:
- Using Perl modules with other package managers
- Deploying Perl
- local::lib
- How to run the tests of a typical Perl module
Misc
It seems easiest to install bundles. This seems to handle dependencies very well. Search CPAN for the package name as Bundel::PACKAGE::NAME
If you get any problems installing using the CPAN module, try downloading and building it manually. There may be dependencies on other non-perl packages.
@INC
Show what @INC is currently set to
- perl -V
or
- perl -e 'print join "\n", @INC'
@INC is set at perl compile time but can be changed by altering the PERL5LIB environment label. It can also be changed at runtime with Perl array commands.
Run the following command to confirm whether a module is found on the @INC
path or not:
- perl -e 'use Foo:Bar;'
If there is no error output the module was found on the path.
Ref: http://alvinalexander.com/blog/post/perl/checking-testing-perl-module-in-inc-include-path
-- Frank Dean - 29 Jun 2017
See Also
-- Frank Dean - 30 Apr 2003
Related Topics: InstallingMacPorts