<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technology Nerd &#187; ppm</title>
	<atom:link href="http://tnerd.com/tag/ppm/feed/" rel="self" type="application/rss+xml" />
	<link>http://tnerd.com</link>
	<description>(Technology, as it happens, When it happens!)</description>
	<lastBuildDate>Thu, 18 Mar 2010 18:42:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='tnerd.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Perl: How to Install Perl Modules in few quick steps</title>
		<link>http://tnerd.com/2008/10/26/perl-how-to-install-perl-modules-in-few-quick-steps/</link>
		<comments>http://tnerd.com/2008/10/26/perl-how-to-install-perl-modules-in-few-quick-steps/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 05:52:38 +0000</pubDate>
		<dc:creator>mnikhil</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[CPAN]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl5lib]]></category>
		<category><![CDATA[pl]]></category>
		<category><![CDATA[pm]]></category>
		<category><![CDATA[ppm]]></category>

		<guid isPermaLink="false">http://tnerd.com/?p=2082</guid>
		<description><![CDATA[Perl enjoys a very ubiquitous presence in the scripting language world, it comes as a default installation in almost all the *IX platforms. One of the reasons that perl is so extensible through the use of perl modules. Perl also has been ported to Windows by ActiveState, making it easily downloadable and installable product on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tnerd.com/wp-content/uploads/2008/10/perl_camel.png" rel="shadowbox[post-2082];player=img;"><img width="134" height="134" alt="" src="http://tnerd.com/wp-content/uploads/2008/10/perl_camel-300x300.png" title="perl_camel" style="border: 0pt none ; float: right; margin-left: 5px; margin-right: 5px;" class="alignright alignnone size-medium wp-image-2083" /></a><a href="http://www.perl.org/" rel="homepage" title="Perl" class="zem_slink">Perl</a> enjoys a very ubiquitous presence in the <a href="http://en.wikipedia.org/wiki/Scripting_language" rel="wikipedia" title="Scripting language" class="zem_slink">scripting language</a> world, it comes as a default installation in almost all the *IX platforms. One of the reasons that perl is so extensible through the use of perl modules. Perl also has been ported to Windows by <a href="http://www.activestate.com/Products/ActivePerl">ActiveState</a>, making it easily downloadable and installable product on Windows too.</p>
<p>With perl, the advantage is that code can be shared in the community as easily&nbsp; as&nbsp; it is written. The code is either written in the form of script or the library files which are termed to be &#8216;packages&#8217; or &#8216;modules&#8217;. The modules should be installed on the system to use them. <strong><a href="http://cpan.org">CPAN</a></strong>, which stands for <strong>C</strong>omprehensive <strong>P</strong>erl <strong>A</strong>rchive <strong>N</strong>etwork, is a very popular place for the perl community to share/distribute the perl code and hosts the largest collection of freely distributable perl code and documentation.</p>
<p><span id="more-2082"></span>Another popular perl module is <strong>PPM</strong> for Windows. <strong>PPM</strong> stands <strong>P</strong>erl <strong>P</strong>ackage <strong>M</strong>anager developed by <a href="http://www.activestate.com/Products/ActivePerl">ActiveState </a>for easy distribution of Windows based perl modules through their network. Most of the libraries or modules are already written and shared on CPAN network, it is often a best practice to check if there is already a <a href="http://en.wikipedia.org/wiki/Perl_module" rel="wikipedia" title="Perl module" class="zem_slink">perl module</a> written for the intentional needs of the yet to be written script. After all it is better to reuse the code to save time and efforts and concentrate on the actual need and nevertheless also follow the principle of <em>&#8216;Do not Reinvent the Wheel&#8217;</em>. <img src='http://tnerd.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>This article attempts to showcase few easy ways of installing perl modules using CPAN and PPM. Although there are definitely many other ways which goes well in synchronization with the perl idiom <em>&#8216;There is more than one way to do it</em>&#8216;.  <img src='http://tnerd.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Before attempting for the installation of the perl module, it is better to check whether the module is already&nbsp; installed. Most common way, for example, to check for the existence of &#8216;Config::IniFiles&#8217; perl module, is to :</p>
<p></p>
<p><code> [nikhil@snerd ~]$ perl -e &quot;use Config::IniFiles; print version: $Config::IniFiles::VERSION&quot; <br /></code></p>
<p><code>version: 2.38<br /></code></p>
<p><code>[nikhil@snerd ~]$&nbsp;</code><code></code></p>
<p>&nbsp;</p>
<p>In this case it has been installed as it prints the version, but if you get an error like this:</p>
<p><code> [nikhil@tnerd ~]$ perl -e 'use Config::Ini;' <br /></code></p>
<p><code>Can't locate Config/Ini.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8/i386-linux-thread-multi &nbsp;/usr/lib/perl5/5.8.8 .) at -e line 1. BEGIN failed--compilation aborted at -e line 1. <br /></code></p>
<p><code>[nikhil@tnerd ~]$ <br /></code></p>
<p><code><br /></code></p>
<p>Then, the module has not been installed yet.</p>
<p>Most of the steps described below are common to Unix and Windows, but have been explicitly described if the step is specific to Windows or Unix wherever necessary.</p>
<p><strong> To install perl module through the CPAN network using the CPAN perl module </strong></p>
<p>PS: Note that, besides the name of the network there is a module named &#8216;<strong><a href="http://www.perl.com/CPAN/modules/by-module/CPAN">CPAN</a></strong>&#8216;, so don&#8217;t be confused. </p>
<p><code> $ sudo perl -M CPAN -e 'install Config::IniFiles' </code></p>
<p><a href="http://en.wikipedia.org/wiki/CPAN">CPAN</a> module has the code to download the latest stable version of module from the CPAN repository online. It does the sanity checks for compatibility with the installed version of the perl, automatically resolves any package dependencies and then builds the modules preparing them for the installation and finally installs the modules in the library directory.</p>
<p>Here in most cases, it is assumed that you are either an administrator/super-user or have a write privileges to your perl&nbsp; installation library, allowing you to install the perl modules.</p>
<p>If you are a normal user and do not have a write access to your system-wide perl installation, you could use your <a href="http://en.wikipedia.org/wiki/Home_directory" rel="wikipedia" title="Home directory" class="zem_slink">home directory</a> to serve as the library location for your scripts. Yes, ordinary users can still install and use modules from their home directory for their development works. However, the script working for the developer may not be usable by others if the script happens to depend on a certain module which is only installed in his home directory but not system-wide. </p>
<p>Well, it&#8217;s not a smart move to ask the users to install the module in their home directories. It is advisable to contact the system support to get the scripts installed on the machine. I am sure, no System administrator would be hesitant to install the module on the machine given its impact value for many users.</p>
<p><strong>To setup perl library folder and install perl module as normal user under one&#8217;s home directory, follow the below procedure:</strong></p>
<p><code> [nikhil@tnerd nikhil]$ echo $0 -bash <br /></code></p>
<p><code>[nikhil@tnerd nikhil]$ </code><code>export PERL5LIB=/nikhil/myperl/lib/perl5/site_perl/5.8.8</code>&nbsp;<code></code></p>
<p><code>[nikhil@tnerd nikhil]$ mkdir $HOME/myperl <br /></code></p>
<p><code>[nikhil@tnerd nikhil]$ perl -V  | grep myperl PERL5LIB=&quot;/nikhil/myperl&quot; /nikhil/myperl </code></p>
<p><code> [nikhil@tnerd ~]$ perl -MCPAN -e shell cpan shell <br /></code></p>
<p><code>-- CPAN exploration and modules installation (v1.7602) ReadLine support available (try 'install Bundle::CPAN') </code></p>
<p><code> cpan&gt; o conf makepl_arg makepl_arg </code></p>
<p><code> cpan&gt; o conf makepl_arg PREFIX=/nikhil/myperl makepl_arg         PREFIX=/nikhil/myperl </code></p>
<p><code> cpan&gt; o conf commit commit: wrote /nikhil/.cpan/CPAN/MyConfig.pm </code></p>
<p>The above sets and saves the CPAN configuration to install the modules in the home directory.</p>
<p><strong>Now proceed to install the module.</strong> Voila, you will be thrilled to see the module getting installed under your home directory.</p>
<p><code> cpan&gt; install Config::IniFiles</code></p>
<p><code> ... ... <br /></code></p>
<p><code>/usr/bin/make test -- OK <br /></code></p>
<p><code>Running make install <br /></code></p>
<p><code>Manifying blib/man3/Config::IniFiles.3pm <br /></code></p>
<p><code>Installing /nikhil/myperl/lib/perl5/site_perl/5.8.8/Config/IniFiles.pm <br /></code></p>
<p><code>Installing /nikhil/myperl/share/man/man3/Config::IniFiles.3pm <br /></code></p>
<p><code>Writing /nikhil/myperl/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/ Config/IniFiles/.packlist <br /></code></p>
<p><code>Appending installation info to /nikhil/myperl/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod <br /></code></p>
<p><code>/usr/bin/make install  -- OK <br /></code></p>
<p><code>cpan&gt; <br /></code></p>
<p><code><br /></code></p>
<p>Now that the <a href="http://perldoc.perl.org/perlfaq8.html#How-do-I-add-a-directory-to-my-include-path-(%40INC)-at-runtime%3f">perl module is installed </a>in the home directory, to use it from the location, one must either</p>
<ul>
<li>set the <a href="http://en.wikipedia.org/wiki/Environment_variable" rel="wikipedia" title="Environment variable" class="zem_slink">environment variable</a> PERL5LIB pointing to the home directory.</li>
</ul>
<p><code> [nikhil@tnerd ~]$ export PERL5LIB=/nikhil/myperl/lib/perl5/site_perl/5.8.8 <br /></code></p>
<p><code>[nikhil@tnerd ~]$ perl -e 'use Config::IniFiles; print $Config::IniFileERSION, &quot;\n&quot;;' <br /></code></p>
<p><code>2.38 <br /></code></p>
<p><code>[nikhil@tnerd ~]$&nbsp;</code></p>
<p align="center">or</p>
<ul>
<li> <a href="http://perldoc.perl.org/lib.html">use the lib</a> module and define the home directory location from where the perl has to search for the modules.</li>
</ul>
<p><code> [nikhil@tnerd ~]$ cat /tmp/test-module.pl <br /></code></p>
<p><code>use lib '/nikhil/myperl/lib/perl5/site_perl/5.8.8';</code></p>
<p><code> use Config::IniFiles; <br /></code></p>
<p><code>print $Config::IniFiles::VERSION,&quot;\n&quot;; <br /></code></p>
<p><code>[nikhil@tnerd ~]$ perl /tmp/test-module.pl</code></p>
<p><code> 2.38 <br /></code></p>
<p><code>[nikhil@tnerd ~]$ <br /></code></p>
<p><code><br /></code></p>
<p>In some rare cases, it is seen that there are some problematic modules whose installation fail with this CPAN method. It is then best suggested to download the module directly from <a href="http://search.cpan.org">search.cpan.org</a> and build manually.</p>
<p><strong>Follow the below steps for manual install</strong>, after downloading the package from search.cpan.org: This works on Unix/Linux platforms, as it requires the make utility. For Windows, nmake utility is available to work on the Makefile(s).</p>
<ol>
<li>Extract the compressed module package using tar/zip utilities</li>
<li>Run perl Makefile.pl (sometimes there is a Makefile.PL, note the case)</li>
<li>make</li>
<li>make test</li>
<li>sudo make install</li>
</ol>
<p><strong>Manual installation of the module as a normal user under home directory:</strong></p>
<ol>
<li>Extract the compressed perl module package using tar/zip</li>
<li>perl Makefile.PL PREFIX=/nikhil/myperl</li>
<li>make</li>
<li>make test</li>
<li>make install</li>
</ol>
<p><strong>To install perl module on Windows through PPM, </strong>ppm is aware of selecting the ActiveState online repository and verifies the metadata repository to check the availability and compatibility of the perl module on the Windows platform.</p>
<p></p>
<p><code>C:\&gt; Perl-5.8.8\bin\ppm install Config::IniFiles <br /></code></p>
<p><code>Downloading ActiveState Package Repository packlist...not modified <br /></code></p>
<p><code>Downloading Config-IniFiles-2.38...done <br /></code></p>
<p><code>Unpacking Config-IniFiles-2.38...done <br /></code></p>
<p><code>Generating HTML for Config-IniFiles-2.38...done <br /></code></p>
<p><code>Updating files in site area...done <br /></code></p>
<p><code>2 files installed <br /></code></p>
<p><code><br /></code></p>
<p>Most of the general module are present on Windows and incase you come across any specific module that is not yet been ported to Windows, you can write to <a href="http://aspn.activestate.com/ASPN/Modules/Perl">ActiveState </a>developers asking for it. Chances are that <a href="http://aspn.activestate.com/ASPN/Modules/Perl">ActiveState</a> developers might have already attempted to port the module to Windows platform but could not due to technical reasons. <strong> </strong></p>
<p>The notable key advantage with both the CPAN and PPM modules is that they automatically resolve the dependency perl packages and install the dependent packages. Lets say, module Foo::f is requested to be installed and Foo::f depends on Bar::b before its installation, and Bar::b is dependent on Cat::c and Dog::d, then the modules Cat::c, Dog::d and Bar::b are also installed along with Foo::f. </p>
<p>This not only significantly saves time searching and recursive installation of the dependent modules but also help in effective and organized package management. This is also the same model that you see these days with the popular package managers like <a href="http://en.wikipedia.org/wiki/Advanced_Packaging_Tool">apt </a>or <a href="http://fedoraproject.org/wiki/Tools/yum">yum </a>for Linux packages.</p>
<p>Hope the steps were easy to understand and follow. Do let us know if there is an easier way of doing this.</p>
<div style="margin-top: 10px; height: 15px; text-align: justify;" class="zemanta-pixie"><img alt="" src="http://img.zemanta.com/pixy.gif?x-id=54aae219-0579-43c8-a8ec-add84a8650ac" style="border: medium none ; float: right;" class="zemanta-pixie-img" /></div>

	Tags: <a href="http://tnerd.com/tag/cpan/" title="CPAN" rel="tag">CPAN</a>, <a href="http://tnerd.com/tag/modules/" title="modules" rel="tag">modules</a>, <a href="http://tnerd.com/tag/perl/" title="perl" rel="tag">perl</a>, <a href="http://tnerd.com/tag/perl5lib/" title="perl5lib" rel="tag">perl5lib</a>, <a href="http://tnerd.com/tag/pl/" title="pl" rel="tag">pl</a>, <a href="http://tnerd.com/tag/pm/" title="pm" rel="tag">pm</a>, <a href="http://tnerd.com/tag/ppm/" title="ppm" rel="tag">ppm</a><br />
]]></content:encoded>
			<wfw:commentRss>http://tnerd.com/2008/10/26/perl-how-to-install-perl-modules-in-few-quick-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
