<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>viaVerio :: Installing Perl5 Modules Yourself</title>
	<copyright>Copyright (c) 2007 Verio Inc. All rights reserved.</copyright>
    <link>http://www.viaverio.com/index.cfm?page_id=464</link>
    <description>Installing Perl5 Modules Yourself</description>
    <language>en-us</language>
    <lastBuildDate>Tue, 06 Nov 2007 15:47:05 GMT</lastBuildDate>
	<managingEditor>sales@verio.net</managingEditor>
	<webMaster>sales@verio.net</webMaster>
	<ttl>5</ttl>	
    <image>
      <title>viaVerio :: Installing Perl5 Modules Yourself</title>
	  <width>149</width>
	  <height>70</height>
	  <link>http://www.viaverio.com</link>
      <url>http://www.viaverio.com/images2/nav/viaverio_logo.gif</url>
    </image>
	<item>
	  <title>Installing Perl5 Modules Yourself</title>
	  <link>http://www.viaverio.com/rss/page_464.rss</link>
	  <guid isPermaLink="true">http://www.viaverio.com/rss/page_464.rss</guid>
	  <pubDate>Wed, 13 Oct 2004 12:00:00 GMT</pubDate>
	  <description>
	    <![CDATA[ &lt;h1&gt;Installing Perl5 Modules Yourself&lt;/h1&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;The content on this page is adapted from &lt;a href=&quot;http://stason.org/TULARC/webmaster/myfaq.html#7&quot;&gt;Answers to Some &lt;br&gt;	Perl/CGI Questions&lt;/a&gt;, by Bekman Stas.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;	&lt;table width=&quot;80%&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;5&quot; align=&quot;center&quot;&gt;&lt;br&gt;		&lt;tr&gt;&lt;br&gt;			&lt;td class=&quot;note&quot;&gt;&lt;br&gt;			&lt;br&gt;&lt;p&gt;&lt;b&gt;NOTE:&lt;/b&gt; The Perl5 module that you wish to install may be included as a pre-packaged module or may &lt;br&gt;				be installable using the &lt;i&gt;vcpan&lt;/i&gt; utility. Both of these methods are preferable to those detailed below. &lt;br&gt;				See the Perl5 module documentation for more details.&lt;/p&gt;&lt;br&gt;			&lt;/td&gt;&lt;br&gt;		&lt;/tr&gt;&lt;br&gt;	&lt;/table&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;Installing &lt;a href=&quot;/index.cfm?page_id=232&quot;&gt;Perl5 Modules&lt;/a&gt; yourself on your Virtual Private Server can be a tricky&lt;br&gt;	exercise. Utilities for installing Perl5 modules generally assume that the installation is being done in the root area of &lt;br&gt;	the file system of the host machine. As a Virtual Private Server user you do not have access to the root area of the host&lt;br&gt;	machine. So, you must install Perl5 modules locally, within your Virtual Private Server file system.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;h2&gt;Installing Perl5 Modules Locally&lt;/h2&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;Normally, the Perl5 module installation procedure includes commands something like these:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% perl5 Makefile.PL&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make test&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make install&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make clean&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;The first command, &lt;i&gt;perl5 Makefile.PL&lt;/i&gt;, directs perl5 to create a &lt;i&gt;makefile&lt;/i&gt; for the new module you are&lt;br&gt;	installing. When installing a perl5 module &lt;i&gt;locally&lt;/i&gt; you must designate the home directory of your perl5 installation &lt;br&gt;	on the command line. That information is used by perl5 to create the makefile. Substitute the following command for &lt;br&gt;	&lt;i&gt;perl5 Makefile.PL&lt;/i&gt;:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% perl5 Makefile.PL PREFIX=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;The value &lt;i&gt;USERNAME&lt;/i&gt; above should be replaced with your Virtual Private Server primary user account name. So the&lt;br&gt;	complete installation process is:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% perl5 Makefile.PL PREFIX=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make test&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make install&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make clean&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;For older modules it may be necessary to designate several other variables on the command line during the module&lt;br&gt;	installation:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% perl5 Makefile.PL PREFIX=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local \&lt;br&gt;INSTALLPRIVLIB=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5 \&lt;br&gt;INSTALLSCRIPT=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/bin \&lt;br&gt;INSTALLSITELIB=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/site_perl \&lt;br&gt;INSTALLBIN=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/bin \&lt;br&gt;INSTALLMAN1DIR=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/man \&lt;br&gt;INSTALLMAN3DIR=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/man/man3&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;To save yourself some typing you can create a file and put these variable assignments above in to a file (&lt;i&gt;FILENAME&lt;/i&gt;)&lt;br&gt;	something like this:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;PREFIX=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local \&lt;br&gt;INSTALLPRIVLIB=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5 \&lt;br&gt;INSTALLSCRIPT=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/bin \&lt;br&gt;INSTALLSITELIB=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/site_perl \&lt;br&gt;INSTALLBIN=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/bin \&lt;br&gt;INSTALLMAN1DIR=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/man \&lt;br&gt;INSTALLMAN3DIR=/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/man/man3&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;Then, each time you install a perl5 module you can use the following syntax:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% perl5 Makefile.PL `cat &lt;i&gt;FILENAME&lt;/i&gt;&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make test&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make install&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;% make clean&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;You also can have a few different local module installation procedures, for example one for production perl and another &lt;br&gt;	for development:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% perl5 Makefile.PL `cat &lt;i&gt;FILENAME&lt;/i&gt;.production`&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;or&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% perl5 Makefile.PL `cat &lt;i&gt;FILENAME&lt;/i&gt;.development`&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;h2&gt;Making scripts find the modules you have installed&lt;/h2&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;When you install perl5 on your Virtual Private Server, all pre-installed modules are installed into these 4 directories&lt;br&gt;	(depending on which version of perl5 you are installing):&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;/usr/local/lib/perl5&lt;br&gt;/usr/local/lib/perl5/i386-bsdos/5.00X&lt;br&gt;/usr/local/lib/perl5/site_perl/i386-bsdos&lt;br&gt;/usr/local/lib/perl5/site_perl&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;These 4 directories are already preset in the perl5&apos;s &lt;i&gt;@INC&lt;/i&gt; array. This array contains the paths that perl5 &lt;br&gt;	searches in order to find modules. If you install perl5 modules locally as described above, you will need to append these &lt;br&gt;	two directories, which are local to your Virtual Private Server, to the &lt;i&gt;@INC&lt;/i&gt; array:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;/usr/home/&amp;lt;username&amp;gt;/usr/local/lib/perl5&lt;br&gt;/usr/home/&amp;lt;username&amp;gt;/usr/local/lib/perl5/site_perl&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;The architecture specific directories are being searched by perl automatically Each time you want to use modules in that&lt;br&gt;	path you should add the following line to your scripts:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;use lib qw(/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5 &lt;br&gt;/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/site_perl);&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;You don&apos;t have to put it into a BEGIN block; the &lt;i&gt;lib.pm&lt;/i&gt; module takes care of that for you. It also adds the&lt;br&gt;	architecture specific directories.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;You also can use a BEGIN block to include your installed modules:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;BEGIN { unshift @INC, qw(/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5 &lt;br&gt;/usr/home/&lt;i&gt;USERNAME&lt;/i&gt;/usr/local/lib/perl5/site_perl); }&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;However, the &lt;i&gt;use lib&lt;/i&gt; construct seems to be cleaner and the &lt;i&gt;unshift @INC&lt;/i&gt; construct doesn&apos;t automatically &lt;br&gt;	add the architecture specific directories to the &lt;i&gt;@INC&lt;/i&gt; array.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;h2&gt;Installing new modules that require locally installed modules&lt;/h2&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;Okay, imagine that you have installed module A in &lt;i&gt;/usr/home/USERNAME/usr/local/lib/perl5&lt;/i&gt;. Now you want to install &lt;br&gt;	a module B that demands module A to be already installed. You know that you have installed the A module, but amazingly B &lt;br&gt;	can&apos;t locate it. Why? Because when you try to install the module B it doesn&apos;t know that you have module A installed locally.&lt;br&gt;	Perl5 searches the basic 4 directories as defined by default in the &lt;i&gt;@INC&lt;/i&gt; array. But your local directories aren&apos;t &lt;br&gt;	listed there.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;The solution is simple. The &lt;i&gt;PERL5LIB&lt;/i&gt; environment variable does the same job in the shell as &lt;i&gt;use lib&lt;/i&gt; does &lt;br&gt;	in your script. So if you use &lt;i&gt;csh&lt;/i&gt; or &lt;i&gt;tcsh&lt;/i&gt;, type the following at the command line:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;% setenv PERL5LIB \&lt;br&gt;/usr/home/&amp;lt;username&amp;gt;/usr/local/lib/perl5:&lt;br&gt;/usr/home/&amp;lt;username&amp;gt;/usr/local/lib/perl5/site_perl&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;Check the man page of your favorite shell how to set the environment variables if you use a shell different from &lt;br&gt;	csh/tcsh. Put this &lt;i&gt;setenv&lt;/i&gt; statement into &lt;i&gt;.login&lt;/i&gt; or another file that is being sourced each time you log in &lt;br&gt;	into your account and you will not have to remember setting it each time you login.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;h2&gt;Module installation using CPAN.pm&lt;/h2&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;An alternative to manually installing perl5 modules is the &lt;i&gt;CPAN.pm&lt;/i&gt; module (see &lt;br&gt;	&lt;a href=&quot;http://www.perl.com/CPAN/&quot;&gt;www.perl.com/CPAN/&lt;/a&gt;) which automates module download and installation. If you &lt;br&gt;	have perl5.004 or higher installed you have it bundled with the distribution. If not, you can download it from CPAN.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;When you initially run the &lt;i&gt;perl5 -MCPAN -e shell&lt;/i&gt; command, it will ask you a few questions. You can use all the&lt;br&gt;	defaults, except for this one:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;Parameters for the &apos;perl Makefile.PL&apos; command? [] &lt;br&gt;PREFIX=/usr/home/&amp;lt;username&amp;gt;/usr/local&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;and this one:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;Parameters for the &apos;make install&apos; command? []&lt;br&gt;INSTALLMAN3DIR=/usr/home/&amp;lt;username&amp;gt;/usr/local/lib/perl5/man/man3&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;When it asks for your favorite CPAN site, try one of these, depending on where your Virtual Private Server &lt;br&gt;	is located:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;p&gt;Dulles, VA:&lt;/p&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;ftp://cpan-du.viaverio.com/pub/CPAN/&lt;/pre&gt;&lt;br&gt;		&lt;br&gt;	&lt;br&gt;&lt;p&gt;San Jose, CA:&lt;/p&gt;&lt;br&gt;		&lt;br&gt;		&lt;pre&gt;ftp://cpan-sj.viaverio.com/pub/CPAN/&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;After configuration of the module is complete, you will see a &lt;i&gt;&amp;gt;&lt;/i&gt; prompt. Then you can try installing modules. &lt;br&gt;	To install the CGI module, do this:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;&amp;gt; install CGI&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;It will fetch the latest CGI module, unpack it, make it, test it and install it into your local area or the directory &lt;br&gt;	you specified as the &lt;i&gt;PREFIX&lt;/i&gt; directory. The command:&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;		&lt;pre&gt;&amp;gt; i /CGI/&lt;/pre&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;will return the list of modules that match that pattern.&lt;/p&gt;&lt;br&gt;	&lt;br&gt;&lt;br&gt;&lt;p&gt;The &lt;i&gt;CPAN.pm&lt;/i&gt; module has more functionality, like checking for the latest modules, for example. Just run &lt;br&gt;	&lt;i&gt;perldoc CPAN&lt;/i&gt; to read the man page.&lt;/p&gt;]]>
	  </description>
	  <author>Content V1</author>
	</item>
  </channel>
</rss> 
