Install Perl For Mac



Mar 13, 2014 To install for the system-perl as root you can use either aptitude or apt-get depending on your personal preferences. If the name of the module in Perl-land is Path::Tiny, then the name of the package in Debian/Ubuntu-land is most likely going to be libpath-tiny-perl. Installing Perl. How to install Perl on Window, macOS and Unix/Linux. Installing Perl on Windows Get Started Installing Perl on macOS Get Started. Install Xcode 5.0.2 or later on your Mac. Xcode is distributed in Mac App Store for free. After installing Xcode, open Xcode and go to Xcode Preferences Downloads, select the Components tab, and click the button next to Command Line Tools to install necessary tools.

1.3. Installing LWP

LWP and the associated modules areavailablein various distributions free from the Comprehensive Perl ArchiveNetwork (CPAN). The main distributionsare listed at the start of Appendix A, 'LWP Modules', although thedetails of which modules are in which distributions changeoccasionally.

If you're using ActivePerl forWindows or MacPerlfor Mac OS 9, you already have LWP. If you're onUnix and you don't already have LWP installed,you'll need to install it from CPAN usinginstructions given in the next section.

To test whether you already have LWP installed:

(The second character in -le is a lowercase L, nota digit one.)

If you see:

or if you see a version number lower than 5.64, you need to installLWP on your system.

There are two ways to install modules: using the CPAN shell or theold-fashioned manual way.

1.3.1. Installing LWP from the CPAN Shell

The CPAN shell is a command-line environmentfor automatically downloading,building, and installing modules from CPAN.

1.3.1.1. Configuring

If you have never used the CPAN shell, you will need to configure itbefore you can use it. It will prompt you for some information beforebuilding its configuration file.

Invoke the CPAN shell by entering the following command at a systemshell prompt:

If you've never run it before,you'll see this:

followed by a number of questions. For each question, the defaultanswer is typically fine, but you may answer otherwise if you knowthat the default setting is wrong or not optimal. Onceyou've answered all the questions, a configurationfile is created and you can start working with the CPAN shell.

1.3.1.2. Obtaining help

If you need help at any time, you can read the CPANshell's manual page by typingperldocCPAN or by starting upthe CPAN shell (with perl-MCPAN-eshell at a systemshell prompt) and entering h at thecpan> prompt:

1.3.1.3. Installing LWP

All you have to do is enter:

The CPAN shell will show messages explaining whatit's up to. You may need to answer questions toconfigure the various modules (e.g., libnet asks for mail hosts andso on for testing purposes).

After much activity, you should then have a fresh copy of LWP on yoursystem, with far less work than installing it manually onedistribution at a time. At the time of this writing, installBundle::LWP installs not just the libwww-perl distribution,but also URI and HTML-Parser. It does not install the HTML-Treedistribution that we'll use in Chapter 9, 'HTML Processing with Trees' and Chapter 10, 'Modifying HTML with Trees'. To do that,enter:

Perl

These commands do not install the HTML-Format distribution, which wasalso once part of the LWP distribution. I do not discuss HTML-Formatin this book, but if you want to install it so that you have acomplete LWP installation, enter this command:

Remember, LWP may be just about the most popular distribution inCPAN, but that's not all there is! Look around theweb-related parts of CPAN (I prefer the interface at http://search.cpan.org, but you can also tryhttp://kobesearch.cpan.org) asthere are dozens of modules, from WWW::Automate to SOAP::Lite, thatcan simplify your web-related tasks.

1.3.2. Installing LWP Manually

The normal Perl module installation procedure is summed up inthe document perlmodinstall. You can read thisby running perldocperlmodinstall at a shell prompt or online athttp://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlmodinstall.html.

CPAN is a network of a large collection of Perl software anddocumentation. See the CPAN FAQ at http://www.cpan.org/misc/cpan-faq.html formore information about CPAN and modules.

1.3.2.1. Download distributions

First, download the moduledistributions.LWP requires several other modules to operate successfully.You'll need to install the distributions given inTable 1-1, in the order in which they are listed.

Table 1-1. Modules used in this book

Distribution

CPAN directory

MIME-Base64

authors/id/G/GA/GAAS

libnet

authors/id/G/GB/GBAAR

HTML-Tagset

authors/id/S/SBURKE

HTML-Parser

authors/id/G/GA/GAAS

URI

authors/id/G/GA/GAAS/URI

Compress-Zlib

authors/id/P/PM/PMQS/Compress-Zlib

Digest-MD5

authors/id/G/GA/GAAS/Digest-MD5

libwww-perl

authors/id/G/GA/GAAS/libwww-perl

HTML-Tree

authors/id/S/SB/SBURKE/HTML-Tree

Fetch these modules from one of the FTP or web sites that form CPAN,listed at http://www.cpan.org/SITES.html andhttp://mirror.cpan.org. SometimesCPAN has several versions of a module in theauthors directory. Be sure to check the versionnumber and get the latest.This book is about the latest version of LWP! Upgrade now!

For example to install MIME-Base64, you might first fetch http://www.cpan.org/authors/id/G/GA/GAAS/ tosee which versions are there, then fetch http://www.cpan.org/authors/id/G/GA/GAAS/MIME-Base64-2.12.tar.gzand install that.

1.3.2.2. Unpack and configure

The distributions are gzipped tar archives of source code.Extracting a distribution creates a directory, and in that directoryis a Makefile.PL Perl program that builds aMakefile for you.

1.3.2.3. Make, test, and install

Compile the code with the make command:

Then make sure everything works on your system with maketest:

If it passes the tests, install it with makeinstall (as the superuser):

PrevNext

When searching a Perl module, sooner or later you will end up on one of two sites sites providing information about CPAN modules.Both Meta CPAN, and search.cpan.orgwill show you a link to download the module, but in most cases that's not what you need.

So how do you really install Perl modules from CPAN?

(As always, some people will disagree with the recommendations below, they probably have not readthe article of Dave Cross, or reachedother conclusions.)

In most cases the installation of a CPAN module works just as installing an app from the Apple Appstore or the Google Play.Except, that these modules are all open source and free software.

Mac

Depending on the Operating System and which Perl distribution you have, the specific instructions differ.In order to make the examples clearer, let's try to install the module called Try::Tiny.

It has its description both on Meta CPAN and onsearch.cpan.org. Both have the Download linksthat we won't click on.

Cases

Cpan Windows

Strawberry Perl or DWIM Perl on Windows

Strawberry Perl,comes with an already configured cpan client. We will use this client to install modules directly from CPAN:

Open the Command Window (Start -> Run -> type in cmd) When you get the 'DOS' prompttype in cpan Path::Tiny.Please note, module names are case sensitive,so typing cpan path::tiny or cpan PATH::TINY will not work!

Also, in normal circumstances, the cpan client is expecting the full name of the module, not one part of the name,and not the name of the zip-file.So cpan Path or cpan Tiny will attempt to install different modules.(One called Path, the other one called Tiny.)

What you need to do is type in:

ActivePerl

There is a graphical tool for this as well, but it might be more simple just to open theCommand Window (Start -> Run -> type cmd). When you get the 'DOS' prompt, type inppm install Path::Tiny. Please note, this too is case sensitive!

The problem you might encounter is that this command uses the 'CPAN store' of ActiveState that for varioustechnical and legal reasons does not carry all the the modules from CPAN. It can also be out-of datecarrying older versions of the modules. On newer versions of ActivePerl you can also enable a realcpan-client that will access the CPAN server just as it does in the case of Strawberry/DWIM Perl above.

GitPerl

TBD.

Cygwin Perl

TBD. Cygwin.

Debian/Ubuntu Linux

If you have root rights, and if you use the system perl located in /usr/bin/perl,then probably the best is to try to install from the package management system of your Linux distribution.If you don't have root rights, you could ask your system administrator to do it on your behalf.

Apparently there is a nice way to find out if a Perl module is on Debian or Ubuntu.

If the module you are looking for is not available in the repositories of your Debian/Ubuntu/etc. distribution(and there are only about 10% of the modules available), or if you don't use the system Perl,then you can follow the instructions with cpan/cpanm below.

To install for the system-perl as root you can use either aptitude or apt-getdepending on your personal preferences.

Install Perl For Mac

If the name of the module in Perl-land is Path::Tiny, then the name of the package in Debian/Ubuntu-landis most likely going to be libpath-tiny-perl.

RedHat/Fedora/CentOS Linux

Sierra

Just as in the case of Debian/Ubuntu above, the instructions here are relevant ifyou use the system perl located in /usr/bin/perl and if you haveroot rights:

Using the package management system:

As Dave Cross mentioned, if you don't know the name of the RH package, you can also use

The subtle difference is that the former installs the named RPM whereas the secondinstalls the RPM that provides the named Perl module.

So if you would like to install the Path::Tiny module then the second command isactually the better one.

If your vendor does not carry this Perl package, you can add other RPM repositories.Check out EPEL, andthe Magnum Solutions CPAN RPM Repositorymaintained by Dave Cross.

Mac OSX

Follow the instructions with cpan/cpanm below.

Using the cpan client

While the cpan program comes with most operating system,and it works well after some configuration, there is probably a better,and certainly lighter solution called cpan minus or cpanm.

Using cpanm

This is for Linux and OSX systems. (For Windows, see described above.)

First, if you don't have it installed yet,then install cpan minus by typing

Once it is installed type:

Mac

If you still have questions related to the installation of Perl modules,please ask them below! I'll try to update this articleto answer those questions and to explain other situations.

Specific instructions for

TODO

Separate explanation of installing using cpan/cpanm as root stepping on the system perl, using local::lib to install in a private directory while using system perl.

Using a manually compiled perl.

Install Perl Module Mac

Using perlbrew, creating 'virtual environments'.

Install Perl For Mac Installer

Published on 2014-03-13

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.Please enable JavaScript to view the comments powered by Disqus.comments powered by Disqus
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.