{"id":790,"date":"2014-02-18T05:59:17","date_gmt":"2014-02-18T05:59:17","guid":{"rendered":"http:\/\/adriangrigoras.com\/blog\/?p=790"},"modified":"2017-02-18T06:00:12","modified_gmt":"2017-02-18T06:00:12","slug":"installing-perl-modules-cpan","status":"publish","type":"post","link":"https:\/\/adriangrigoras.com\/blog\/installing-perl-modules-cpan\/","title":{"rendered":"Installing Perl modules using CPAN"},"content":{"rendered":"<p>Installing Perl modules required by various open source software is a routine tasks for sysadmins. <strong>Installing Perl modules manually<\/strong> by resolving all the dependencies is\u00a0 tedious and annoying process.<br \/>\n<code><\/code><br \/>\n<strong>Installing Perl modules using CPAN<\/strong> is a better solution, as it resolves all the dependencies automatically. In this article, let us review how to install Perl modules on Linux using both manual and CPAN method.<br \/>\n<span id=\"more-182\"><\/span><br \/>\n<code><\/code><br \/>\nWhen a Perl module is not installed, application will display the following error message. In this example, XML::Parser Perl module is missing.<\/p>\n<pre><strong>Can't locate<\/strong> XML\/parser.pm in @INC (@INC contains:\r\n\/usr\/lib\/perl5\/5.10.0\/i386-linux-thread-multi\r\n\/usr\/lib\/perl5\/5.10.0\r\n\/usr\/local\/lib\/perl5\/site_perl\/5.10.0\/i386-linux-thread-multi\r\n\/usr\/local\/lib\/perl5\/site_perl\/5.10.0\r\n\/usr\/lib\/perl5\/vendor_perl\/5.10.0\/i386-linux-thread-multi\r\n\/usr\/lib\/perl5\/vendor_perl\/5.10.0 \/usr\/lib\/perl5\/vendor_perl\r\n\/usr\/lib\/perl5\/site_perl\/5.10.0 .)<\/pre>\n<h2>Install Perl Modules Manually<\/h2>\n<h3>Download Perl module<\/h3>\n<p>Go to <a href=\"http:\/\/search.cpan.org\/\" target=\"_blank\">CPAN Search<\/a> website and search for the module that you wish to download. In this example, let us search, download and install XML::Parser Perl module. I have downloaded the XML-Parser-2.36.tar.gz to \/home\/download<\/p>\n<pre># cd \/home\/download\r\n# gzip -d XML-Parser-2.36.tar.gz\r\n# tar xvf XML-Parser-2.36.tar\r\n# cd XML-Parser-2.36<\/pre>\n<h3>Build the perl module<\/h3>\n<pre># <strong>perl Makefile.PL\r\n<\/strong>Checking if your kit is complete...\r\nLooks good\r\nWriting Makefile for XML::Parser::Expat\r\nWriting Makefile for XML::Parser\r\n# <strong>make<\/strong>\r\n# <strong>make test<\/strong><\/pre>\n<h3>Install the perl module<\/h3>\n<pre># <strong>make install<\/strong><\/pre>\n<p>This is very simple for one module with no dependencies. Typically, Perl modules will be dependent on several other modules. Chasing all these dependencies one-by-one can be very painful and annoying task. I recommend the CPAN method of installation as shown below. Use the manual method only if the server is not connected to the Internet.<\/p>\n<h2>Install Perl Modules using CPAN automatically<\/h2>\n<h3>Verify whether CPAN is already installed<\/h3>\n<p>To install Perl modules using CPAN, make sure the cpan command is working. You should have the CPAN perl module installed before you can install any other Perl modules using CPAN. In this example, CPAN module is not installed.<\/p>\n<pre># <strong>cpan<\/strong>\r\n-bash: cpan: command not found\r\n\r\n# <strong>perl -MCPAN -e shell<\/strong>\r\nCan't locate CPAN.pm in @INC (@INC contains:\r\n\/usr\/lib\/perl5\/5.10.0\/i386-linux-thread-multi\r\n\/usr\/lib\/perl5\/5.10.0\r\n\/usr\/local\/lib\/perl5\/site_perl\/5.10.0\/i386-linux-thread-multi\r\n\/usr\/local\/lib\/perl5\/site_perl\/5.10.0\r\n\/usr\/lib\/perl5\/vendor_perl\/5.10.0\/i386-linux-thread-multi\r\n\/usr\/lib\/perl5\/vendor_perl\/5.10.0\r\n\/usr\/lib\/perl5\/vendor_perl \/usr\/lib\/perl5\/site_perl\/5.10.0 .).\r\nBEGIN failed--compilation aborted.<\/pre>\n<h3>Install the CPAN module using yum<\/h3>\n<pre># <strong>yum install perl-CPAN<\/strong><\/pre>\n<p>Output of yum install perl-CPAN command:<\/p>\n<p><center><\/p>\n<div><\/div>\n<p><\/center><\/p>\n<pre>Loaded plugins: refresh-packagekit\r\nupdates-newkey                       | 2.3 kB     00:00\r\nprimary.sqlite.bz2                   | 2.4 MB     00:00\r\nSetting up Install Process\r\nParsing package install arguments\r\n\r\nResolving Dependencies\r\nTransaction Summary\r\n=============================================================================\r\nInstall      5 Package(s)\r\nUpdate       0 Package(s)\r\nRemove       0 Package(s)\r\n\r\nTotal download size: 1.0 M\r\nIs this ok [y\/N]: y\r\nDownloading Packages:\r\n(1\/5): perl-ExtUtils-ParseXS-2.18-31.fc9.i386.rpm     |  30 kB     00:00\r\n(2\/5): perl-Test-Harness-2.64-31.fc9.i386.rpm         |  70 kB     00:00\r\n(3\/5): perl-CPAN-1.9205-31.fc9.i386.rpm               | 217 kB     00:00\r\n(4\/5): perl-ExtUtils-MakeMaker-6.36-31.fc9.i386.rpm   | 284 kB     00:00\r\n(5\/5): perl-devel-5.10.0-31.fc9.i386.rpm              | 408 kB     00:00\r\n<strong>\r\nInstalling     : perl-ExtUtils-ParseXS                             [1\/5]\r\nInstalling     : perl-devel                                        [2\/5]\r\nInstalling     : perl-Test-Harness                                 [3\/5]\r\nInstalling     : perl-ExtUtils-MakeMaker                           [4\/5]\r\nInstalling     : perl-CPAN                                         [5\/5]\r\n\r\n<\/strong>\r\n<strong>Installed: perl-CPAN.i386 0:1.9205-31.fc9\r\n<\/strong>Dependency Installed:\r\n  perl-ExtUtils-MakeMaker.i386 0:6.36-31.fc9\r\n  perl-ExtUtils-ParseXS.i386 1:2.18-31.fc9\r\n  perl-Test-Harness.i386 0:2.64-31.fc9\r\n  perl-devel.i386 4:5.10.0-31.fc9\r\n<strong>Complete!<\/strong><\/pre>\n<h3>Configure cpan the first time<\/h3>\n<p>The first time when you execute cpan, you should set some configuration parameters as shown below. I have shown only the important configuration parameters below. Accept all the default values by pressing enter.<\/p>\n<p><strong>Note:<\/strong> Make sure to execute \u201c<strong>o conf commit<\/strong>\u201d in the cpan prompt after the configuration to save the settings.<\/p>\n<pre># <strong>cpan<\/strong>\r\n\r\nSorry, we have to rerun the configuration dialog for CPAN.pm due\r\nto some missing parameters...\r\n\r\nCPAN build and cache directory? <strong>[\/root\/.cpan]\r\n<\/strong>Download target directory? [\/root\/.cpan\/sources]\r\nDirectory where the build process takes place? [\/root\/.cpan\/build]\r\n\r\nAlways commit changes to config variables to disk? <strong>[no]<\/strong>\r\nCache size for build directory (in MB)? [100]\r\nLet the index expire after how many days? [1]\r\n\r\nPerform cache scanning (atstart or never)? <strong>[atstart]<\/strong>\r\nCache metadata (yes\/no)? [yes]\r\nPolicy on building prerequisites (follow, ask or ignore)? [ask]\r\n\r\nParameters for the 'perl Makefile.PL' command? <strong>[]<\/strong>\r\nParameters for the 'perl Build.PL' command? []\r\n\r\nYour ftp_proxy? <strong>[]<\/strong>\r\nYour http_proxy? []\r\nYour no_proxy? []\r\nIs it OK to try to connect to the Internet? [yes]\r\n\r\nFirst, pick a nearby continent and country by typing in the number(s)\r\n(1) Africa\r\n(2) Asia\r\n(3) Central America\r\n(4) Europe\r\n(5) North America\r\n(6) Oceania\r\n(7) South America\r\n<strong>Select your continent<\/strong> (or several nearby continents) [] 5\r\n\r\n(1) Bahamas\r\n(2) Canada\r\n(3) Mexico\r\n(4) United States\r\n<strong>Select your country<\/strong> (or several nearby countries) [] 4\r\n\r\n(2) ftp:\/\/carroll.cac.psu.edu\/pub\/CPAN\/\r\n(3) ftp:\/\/cpan-du.viaverio.com\/pub\/CPAN\/\r\n(4) ftp:\/\/cpan-sj.viaverio.com\/pub\/CPAN\/\r\n(5) ftp:\/\/cpan.calvin.edu\/pub\/CPAN\r\n(6) ftp:\/\/cpan.cs.utah.edu\/pub\/CPAN\/\r\ne.g. '1 4 5' or '7 1-4 8' <strong>[] 2-16<\/strong>\r\n\r\ncpan[1]&gt; <strong>o conf commit<\/strong>\r\ncommit: wrote '\/usr\/lib\/perl5\/5.10.0\/CPAN\/Config.pm'\r\n\r\ncpan[2]&gt; <strong>quit<\/strong>\r\nNo history written (no histfile specified).\r\nLockfile removed.<\/pre>\n<h3>Install Perl Modules using CPAN<\/h3>\n<p>You can use one of the following method to install a Perl module using cpan.<\/p>\n<pre># <strong>\/usr\/bin\/perl -MCPAN -e 'install Email::Reply'\r\n\r\n<\/strong>(or)\r\n\r\n# <strong>cpan<\/strong>\r\ncpan shell -- CPAN exploration and modules installation (v1.9205)\r\nReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?)\r\n\r\ncpan[1]&gt; <strong>install \"Email::Reply\";<\/strong><\/pre>\n<p>Output of above perl install command:<\/p>\n<pre>CPAN: Storable loaded ok (v2.18)\r\nGoing to read \/root\/.cpan\/Metadata\r\nDatabase was generated on Mon, 15 Sep 2008 11:02:52 GMT\r\n\r\nRunning install for module 'Email::Reply'\r\nRunning make for R\/RJ\/RJBS\/Email-Reply-1.202.tar.gz\r\nCPAN: LWP::UserAgent loaded ok (v2.036)\r\nCPAN: Time::HiRes loaded ok (v1.9711)\r\nFetching with LWP:\r\nftp:\/\/carroll.cac.psu.edu\/pub\/CPAN\/authors\/id\/R\/RJ\/RJBS\/Email-Reply-1.202.tar.gz\r\n\r\nCPAN: checksum security checks disabled because Digest::SHA not installed.\r\nPlease consider installing the Digest::SHA module.\r\n\r\nCPAN: Compress::Zlib loaded ok (v2.008)\r\nEmail-Reply-1.202\/\r\nEmail-Reply-1.202\/Changes\r\nCPAN: File::Temp loaded ok (v0.18)\r\nWarning: prerequisite Email::Abstract 2.01 not found.\r\nWarning: prerequisite Email::MIME::Creator 1.41 not found.\r\nWriting Makefile for Email::Reply\r\n---- Unsatisfied dependencies detected during ----\r\n----       RJBS\/Email-Reply-1.202.tar.gz      ----\r\n<strong>Email::Abstract [requires]\r\nEmail::MIME::Creator [requires]\r\n<\/strong>Shall I follow them and prepend them to the queue\r\n\r\nof modules we are processing right now? [yes]\r\n[Note: CPAN automatically detects that Email::Abstract\r\n       and Email::MIME::Creator is required]\r\n\r\nFetching with LWP:\r\nftp:\/\/server\/pub\/CPAN\/authors\/id\/R\/RJ\/RJBS\/Email-Abstract-2.134.tar.gz\r\nmake -- OK\r\nmake install  -- OK\r\n\r\nFetching with LWP:\r\nftp:\/\/server\/pub\/CPAN\/authors\/id\/R\/RJ\/RJBS\/Email-MIME-Creator-1.454.tar.gz\r\nmake -- OK\r\nmake install  -- OK\r\n\r\nWarning: prerequisite Email::Simple::Creator 1.4 not found.\r\nWriting Makefile for Email::MIME::Creator\r\n<strong>Email::Simple::Creator [requires]\r\n<\/strong>Shall I follow them and prepend them to the queue\r\nof modules we are processing right now? [yes]\r\n[Note: CPAN automatically detects that Simple::Creator is required]\r\n\r\nFetching with LWP:\r\nftp:\/\/carroll.cac.psu.edu\/pub\/CPAN\/authors\/id\/R\/RJ\/RJBS\/Simple-Creator.tar.gz\r\nmake -- OK\r\nmake install  -- OK\r\n\r\nFetching with LWP:\r\nCPAN.pm: Going to build R\/RJ\/RJBS\/Email-Reply-1.202.tar.gz\r\n\r\nmake -- OK\r\nmake install  -- OK<\/pre>\n<p>In the example above, Email::Reply is dependent on the several other modules.<strong>CPAN automatically resolves the dependencies<\/strong> and installs Email::Reply and all the dependent Perl modules.<\/p>\n<p>&nbsp;<\/p>\n<p>source:\u00a0http:\/\/www.thegeekstuff.com\/2008\/09\/how-to-install-perl-modules-manually-and-using-cpan-command\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing Perl modules required by various open source software is a routine tasks for sysadmins. Installing Perl modules manually by resolving all the dependencies is\u00a0 tedious and annoying process. Installing Perl modules using CPAN is a better solution, as it resolves all the dependencies automatically. In this article, let us review how to install Perl\u2026 <span class=\"read-more\"><a href=\"https:\/\/adriangrigoras.com\/blog\/installing-perl-modules-cpan\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-790","post","type-post","status-publish","format-standard","hentry","category-perl"],"_links":{"self":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/comments?post=790"}],"version-history":[{"count":1,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/790\/revisions"}],"predecessor-version":[{"id":791,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/790\/revisions\/791"}],"wp:attachment":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/media?parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/categories?post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/tags?post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}