<p>I get this error:</p>

<p><code>Can't locate Foo.pm in @INC</code></p>

<p>Is there an easier way to install it than downloading, untarring, making, etc?</p>

[{'answer_id': 65876, 'author': 'dreeves', 'author_id': 4234, 'author_profile': 'https://Stackoverflow.com/users/4234', 'pm_score': 4, 'selected': False, 'text': "<p><code>sudo perl -MCPAN -e 'install Foo'</code></p>\n"}, {'answer_id': 65883, 'author': 'Benedikt Waldvogel', 'author_id': 4308, 'author_profile': 'https://Stackoverflow.com/users/4308', 'pm_score': 9, 'selected': True, 'text': '<p><strong>On Unix</strong>:</p>\n<p>usually you start <em>cpan</em> in your shell:</p>\n<p><code>$ cpan</code></p>\n<p>and type</p>\n<p><code>install Chocolate::Belgian</code></p>\n<p>or in short form:</p>\n<p><code>cpan Chocolate::Belgian</code></p>\n<p><strong>On Windows</strong>:</p>\n<blockquote>\n<p>If you\'re using ActivePerl on Windows, the <a href="http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#pkg_operations" rel="noreferrer">PPM (Perl Package Manager)</a> has much of the same functionality as CPAN.pm.</p>\n</blockquote>\n<p>Example:</p>\n<p><code>$ ppm</code><br/>\n<code>ppm&gt; search net-smtp</code><br/>\n<code>ppm&gt; install Net-SMTP-Multipart</code></p>\n<p><strong>see <a href="http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules" rel="noreferrer">How do I install Perl modules?</a> in the CPAN FAQ</strong></p>\n<p>Many distributions ship a lot of perl modules as packages.</p>\n<ul>\n<li>Debian/Ubuntu: <code>apt-cache search \'perl$\'</code></li>\n<li>Arch Linux: <code>pacman -Ss \'^perl-\'</code></li>\n<li>Gentoo: category <code>dev-perl</code></li>\n</ul>\n<p>You should <em>always</em> prefer them as you benefit from automatic (security) <strong>updates</strong> and the ease of <strong>removal</strong>. This can be pretty tricky with the <em>cpan</em> tool itself.</p>\n<p>For Gentoo there\'s a nice tool called <strong><a href="https://wiki.gentoo.org/wiki/Project:Perl/g-cpan" rel="noreferrer">g-cpan</a></strong> which builds/installs the module from CPAN and creates a Gentoo package (<a href="http://en.wikipedia.org/wiki/Ebuild" rel="noreferrer">ebuild</a>) for you.</p>\n'}, {'answer_id': 65911, 'author': 'Otto', 'author_id': 9594, 'author_profile': 'https://Stackoverflow.com/users/9594', 'pm_score': 5, 'selected': False, 'text': "<p>If you're on Ubuntu and you want to install the pre-packaged perl module (for example, geo::ipfree) try this:</p>\n\n<pre>\n    $ apt-cache search perl geo::ipfree\n    libgeo-ipfree-perl - A look up country of ip address Perl module\n\n    $ sudo apt-get install libgeo-ipfree-perl\n</pre>\n"}, {'answer_id': 65945, 'author': 'PW.', 'author_id': 927, 'author_profile': 'https://Stackoverflow.com/users/927', 'pm_score': 0, 'selected': False, 'text': '<p>On Windows with the ActiveState distribution of Perl, use the <a href="http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#pkg_operations" rel="nofollow noreferrer">ppm</a> command.</p>\n'}, {'answer_id': 65960, 'author': 'JWHEAT', 'author_id': 7079, 'author_profile': 'https://Stackoverflow.com/users/7079', 'pm_score': 2, 'selected': False, 'text': "<p>2 ways that I know of :</p>\n\n<p><strong>USING PPM :</strong></p>\n\n<p>With <strong>Windows</strong> (ActivePerl) I've used ppm</p>\n\n<p>from the command line type ppm. At the ppm prompt ...  </p>\n\n<pre><code>ppm&gt; install foo\n</code></pre>\n\n<p>or </p>\n\n<pre><code>ppm&gt; search foo\n</code></pre>\n\n<p>to get a list of foo modules available.  Type <strong>help</strong> for all the commands</p>\n\n<p><strong>USING CPAN :</strong></p>\n\n<p>you can also use CPAN like this (<strong>*nix systems</strong>) :</p>\n\n<pre><code>perl -MCPAN -e 'shell'\n</code></pre>\n\n<p>gets you a prompt</p>\n\n<pre><code>cpan&gt;\n</code></pre>\n\n<p>at the prompt ...</p>\n\n<pre><code>cpan&gt; install foo  (again to install the foo module)\n</code></pre>\n\n<p>type h to get a list of commands for cpan</p>\n"}, {'answer_id': 66430, 'author': 'Dave Rolsky', 'author_id': 9832, 'author_profile': 'https://Stackoverflow.com/users/9832', 'pm_score': 5, 'selected': False, 'text': '<p>I note some folks suggesting one run cpan under sudo. That used to be necessary to install into the system directory, but modern versions of the CPAN shell allow you to configure it to use sudo <strong>just</strong> for installing. This is much safer, since it means that tests don\'t run as root.</p>\n\n<p>If you have an old CPAN shell, simply install the new cpan ("install CPAN") and when you reload the shell, it should prompt you to configure these new directives.</p>\n\n<p>Nowadays, when I\'m on a system with an old CPAN, the first thing I do is update the shell and set it up to do this so I can do most of my cpan work as a normal user.</p>\n\n<p>Also, I\'d strongly suggest that Windows users investigate <a href="http://strawberryperl.com" rel="noreferrer">strawberry Perl</a>. This is a version of Perl that comes packaged with a pre-configured CPAN shell as well as a compiler. It also includes some hard-to-compile Perl modules with their external C library dependencies, notably XML::Parser. This means that you can do the same thing as every other Perl user when it comes to installing modules, and things tend to "just work" a lot more often.</p>\n'}, {'answer_id': 67720, 'author': 'brian d foy', 'author_id': 2766176, 'author_profile': 'https://Stackoverflow.com/users/2766176', 'pm_score': 4, 'selected': False, 'text': '<p>A couple of people mentioned the cpan utility, but it\'s more than just starting a shell. Just give it the modules that you want to install and let it do it\'s work. </p>\n\n<pre><code>$prompt&gt; cpan Foo::Bar\n</code></pre>\n\n<p>If you don\'t give it any arguments it starts the CPAN.pm shell. This works on Unix, Mac, and should be just fine on Windows (especially Strawberry Perl).</p>\n\n<p>There are several other things that you can do with the cpan tool as well. Here\'s a summary of the current features (which might be newer than the one that comes with CPAN.pm and perl):</p>\n\n<pre class="lang-none prettyprint-override"><code>-a\nCreates the CPAN.pm autobundle with CPAN::Shell-&gt;autobundle.\n\n-A module [ module ... ]\nShows the primary maintainers for the specified modules\n\n-C module [ module ... ]\nShow the Changes files for the specified modules\n\n-D module [ module ... ]\nShow the module details. This prints one line for each out-of-date module (meaning,\nmodules locally installed but have newer versions on CPAN). Each line has three columns:\nmodule name, local version, and CPAN version.\n\n-L author [ author ... ]\nList the modules by the specified authors.\n\n-h\nPrints a help message.\n\n-O\nShow the out-of-date modules.\n\n-r\nRecompiles dynamically loaded modules with CPAN::Shell-&gt;recompile.\n\n-v\nPrint the script version and CPAN.pm version.\n</code></pre>\n'}, {'answer_id': 69838, 'author': 'Corion', 'author_id': 11253, 'author_profile': 'https://Stackoverflow.com/users/11253', 'pm_score': 3, 'selected': False, 'text': '<p>Also see <a href="http://perlmonks.org/?node=693828" rel="noreferrer">Yes, even you can use CPAN</a>. It shows how you can use CPAN without having root or sudo access.</p>\n'}, {'answer_id': 73546, 'author': 'Dave Cross', 'author_id': 7231, 'author_profile': 'https://Stackoverflow.com/users/7231', 'pm_score': 3, 'selected': False, 'text': "<p>Lots of recommendation for <code>CPAN.pm</code>, which is great, but if you're using <code>Perl 5.10</code> then you've also got access to <code>CPANPLUS.pm</code> which is like <code>CPAN.pm</code> but better.</p>\n\n<p>And, of course, it's available on <code>CPAN</code> for people still using older versions of Perl. Why not try:</p>\n\n<pre><code>$ cpan CPANPLUS\n</code></pre>\n"}, {'answer_id': 75985, 'author': 'mikegrb', 'author_id': 13462, 'author_profile': 'https://Stackoverflow.com/users/13462', 'pm_score': 3, 'selected': False, 'text': '<p>Otto made a <a href="https://stackoverflow.com/questions/65865/cant-locate-foopm-in-inc-how-to-install-a-missing-perl-module#65911">good suggestion</a>.  This works for Debian too, as well as any other Debian derivative.  The missing piece is what to do when apt-cache search doesn\'t find something.</p>\n\n<pre><code>$ sudo apt-get install dh-make-perl build-essential apt-file\n$ sudo apt-file update\n</code></pre>\n\n<p>Then whenever you have a random module you wish to install:</p>\n\n<pre><code>$ cd ~/some/path\n$ dh-make-perl --build --cpan Some::Random::Module\n$ sudo dpkg -i libsome-random-module-perl-0.01-1_i386.deb\n</code></pre>\n\n<p>This will give you a deb package that you can install to get Some::Random::Module.  One of the big benefits here is man pages and sample scripts in addition to the module itself will be placed in your distro\'s location of choice.  If the distro ever comes out with an official package for a newer version of Some::Random::Module, it will automatically be installed when you apt-get upgrade.</p>\n'}, {'answer_id': 309989, 'author': 'Bruce Alderman', 'author_id': 311, 'author_profile': 'https://Stackoverflow.com/users/311', 'pm_score': 2, 'selected': False, 'text': '<p>On Fedora you can use</p>\n\n<pre><code># yum install foo\n</code></pre>\n\n<p>as long as Fedora has an existing package for the module.</p>\n'}, {'answer_id': 3590064, 'author': 'Philip Potter', 'author_id': 276952, 'author_profile': 'https://Stackoverflow.com/users/276952', 'pm_score': 6, 'selected': False, 'text': '<p>Try <a href="http://search.cpan.org/perldoc/App::cpanminus" rel="noreferrer">App::cpanminus</a>:</p>\n\n<pre><code># cpanm Chocolate::Belgian\n</code></pre>\n\n<p>It\'s great for just getting stuff installed. It provides none of the more complex functionality of CPAN or CPANPLUS, so it\'s easy to use, provided you know which module you want to install. If you haven\'t already got cpanminus, just type:</p>\n\n<pre><code># cpan App::cpanminus\n</code></pre>\n\n<p>to install it.</p>\n\n<p>It is also possible to install it without using cpan at all.  The basic bootstrap procedure is,</p>\n\n<pre><code>curl -L http://cpanmin.us | perl - --sudo App::cpanminus\n</code></pre>\n\n<p>For more information go to the App::cpanminus page and look at the section on installation.</p>\n'}, {'answer_id': 6089068, 'author': 'Mandar Pande', 'author_id': 673018, 'author_profile': 'https://Stackoverflow.com/users/673018', 'pm_score': 2, 'selected': False, 'text': '<p>Even it should work:</p>\n\n<pre><code>cpan -i module_name\n</code></pre>\n'}, {'answer_id': 6089839, 'author': 'clt60', 'author_id': 632407, 'author_profile': 'https://Stackoverflow.com/users/632407', 'pm_score': 3, 'selected': False, 'text': '<p>Already answered and accepted answer - but anyway:</p>\n\n<p>IMHO the easiest way installing CPAN modules (on unix like systems, and have no idea about the wondows) is:</p>\n\n<pre><code>curl -L http://cpanmin.us | perl - --sudo App::cpanminus\n</code></pre>\n\n<p>The above is installing the "zero configuration CPAN modules installer" called <code>cpanm</code>. (Can take several minutes to install - don\'t break the process)</p>\n\n<p>and after - simply:</p>\n\n<pre><code>cpanm Foo\ncpanm Module::One\ncpanm Another::Module\n</code></pre>\n'}, {'answer_id': 13318638, 'author': 'jaxbihani', 'author_id': 1813823, 'author_profile': 'https://Stackoverflow.com/users/1813823', 'pm_score': 3, 'selected': False, 'text': '<p>Many times it does happen that cpan install command fails with the message like\n<strong>"make test had returned bad status, won\'t install without force"</strong></p>\n\n<p>In that case following is the way to install the module:</p>\n\n<pre><code>perl -MCPAN -e "CPAN::Shell-&gt;force(qw(install Foo::Bar));"\n</code></pre>\n'}, {'answer_id': 15024907, 'author': 'Myforwik', 'author_id': 70189, 'author_profile': 'https://Stackoverflow.com/users/70189', 'pm_score': 2, 'selected': False, 'text': '<p>On ubuntu most perl modules are already packaged, so installing is much faster than most other systems which have to compile.</p>\n\n<p>To install <code>Foo::Bar</code> at a commmand prompt for example usually you just do:</p>\n\n<pre><code>sudo apt-get install libfoo-bar-perl\n</code></pre>\n\n<p>Sadly not all modules follow that naming convention.</p>\n'}, {'answer_id': 18748245, 'author': 'venkrao', 'author_id': 1508423, 'author_profile': 'https://Stackoverflow.com/users/1508423', 'pm_score': 2, 'selected': False, 'text': "<p>If you want to put the new module into a custom location that your cpan shell isn't configured to use, then perhaps, the following will be handy.</p>\n\n<pre><code> #wget &lt;URL to the module.tgz&gt;\n ##unpack\n perl Build.PL\n./Build destdir=$HOME install_base=$HOME\n./Build destdir=$HOME install_base=$HOME install\n</code></pre>\n"}, {'answer_id': 23646437, 'author': 'Chankey Pathak', 'author_id': 257635, 'author_profile': 'https://Stackoverflow.com/users/257635', 'pm_score': 3, 'selected': False, 'text': '<p>Use cpan command as <code>cpan Modulename</code></p>\n\n<pre><code>$ cpan HTML::Parser\n</code></pre>\n\n<p>To install dependencies automatically follow the below</p>\n\n<pre><code>$ perl -MCPAN -e shell\ncpan[1]&gt;  o conf prerequisites_policy follow\ncpan[2]&gt;  o conf commit\nexit\n</code></pre>\n\n<p>I prefer <a href="https://metacpan.org/pod/App::cpanminus" rel="noreferrer">App::cpanminus</a>, it installs dependencies automatically. Just do</p>\n\n<pre><code>$ cpanm HTML::Parser\n</code></pre>\n'}, {'answer_id': 23754365, 'author': 'Chris Forever', 'author_id': 3655058, 'author_profile': 'https://Stackoverflow.com/users/3655058', 'pm_score': 2, 'selected': False, 'text': '<p>Sometimes you can use the <code>yum search foo</code> to search the relative perl module, then use <code>yum install xxx</code> to install.</p>\n'}, {'answer_id': 26650808, 'author': 'Michal Ingeli', 'author_id': 830716, 'author_profile': 'https://Stackoverflow.com/users/830716', 'pm_score': 2, 'selected': False, 'text': "<p>On <code>Fedora Linux</code> or <code>Enterprise Linux</code>, <code>yum</code> also tracks perl library dependencies. So, if the perl module is available, and some rpm package exports that dependency, it will install the right package for you.</p>\n\n<pre><code>yum install 'perl(Chocolate::Belgian)'\n</code></pre>\n\n<p>(most likely perl-Chocolate-Belgian package, or even ChocolateFactory package)</p>\n"}, {'answer_id': 32884636, 'author': 'Kamal Nayan', 'author_id': 4414367, 'author_profile': 'https://Stackoverflow.com/users/4414367', 'pm_score': 1, 'selected': False, 'text': '<p>Simply executing <code>cpan Foo::Bar</code> on shell would serve the purpose.</p>\n'}, {'answer_id': 40426333, 'author': 'Ed Dunn', 'author_id': 4204127, 'author_profile': 'https://Stackoverflow.com/users/4204127', 'pm_score': 1, 'selected': False, 'text': '<p>Seems like you\'ve already got your answer but I figured I\'d chime in.  This is what I do in some scripts on an Ubuntu (or debian server)</p>\n\n<pre><code>#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n#I\'ve gotten into the habit of setting this on all my scripts, prevents weird path issues if the script is not being run by root\n$ENV{\'PATH\'} = \'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\';\n\n#Fill this with the perl modules required for your project\nmy @perl = qw(LWP::Simple XML::LibXML MIME::Lite DBI DateTime Config::Tiny Proc::ProcessTable);\n\nchomp(my $curl = `which curl`);\n\nif(!$curl){ system(\'apt-get install curl -y &gt; /dev/null\'); }\n\nchomp(my $cpanm = system(\'/bin/bash\', \'-c\', \'which cpanm &amp;&gt;/dev/null\'));\n\n#installs cpanm if missing\nif($cpanm){ system(\'curl -s -L http://cpanmin.us | perl - --sudo App::cpanminus\'); }\n\n#loops through required modules and installs them if missing\nforeach my $x (@perl){\n    eval "use $x";\n    if($@){\n        system("cpanm $x");\n        eval "use $x";\n    }\n}\n</code></pre>\n\n<p>This works well for me, maybe there is something here you can use.</p>\n'}, {'answer_id': 41360933, 'author': 'Mister X', 'author_id': 2422264, 'author_profile': 'https://Stackoverflow.com/users/2422264', 'pm_score': 2, 'selected': False, 'text': "<p>Easiest way for me is this:</p>\n\n<pre><code>PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install DateTime::TimeZone'\n</code></pre>\n\n<p>a) automatic recursive dependency detection/resolving/installing </p>\n\n<p>b) it's a shell onliner, good for setup-scripts</p>\n"}, {'answer_id': 58559309, 'author': 'vinc17', 'author_id': 3782797, 'author_profile': 'https://Stackoverflow.com/users/3782797', 'pm_score': 2, 'selected': False, 'text': '<p><strong>Secure solution</strong></p>\n\n<p>Many answers mention the use of the <code>cpan</code> utility (which uses <code>CPAN.pm</code>) without a word on security. By default, <code>CPAN</code> 2.27 and earlier configures <code>urllist</code> to use a http URL (namely, <a href="http://www.cpan.org/" rel="nofollow noreferrer">http://www.cpan.org/</a>), which allows MITM attacks, thus is insecure. This is what is used to download the <code>CHECKSUMS</code> files, so that it needs to be changed to a secure URL (e.g. <a href="https://www.cpan.org/" rel="nofollow noreferrer">https://www.cpan.org/</a>).</p>\n\n<p>So, after running cpan and accepting the default configuration, you need to modify the generated <code>MyConfig.pm</code> file (the full path is output) in the following way. Replace</p>\n\n<pre><code>\'urllist\' =&gt; [q[http://www.cpan.org/]],\n</code></pre>\n\n<p>by</p>\n\n<pre><code>\'urllist\' =&gt; [q[https://www.cpan.org/]],\n</code></pre>\n\n<p>Note: https is not sufficient; you also need a web site you can trust. So, be careful if you want to choose some arbitrary mirror.</p>\n\n<p>Then you can use <code>cpan</code> in the usual way.</p>\n\n<p>My <a href="https://rt.cpan.org/Public/Bug/Display.html?id=130819" rel="nofollow noreferrer">bug report</a> on rt.cpan.org about the insecure URL.</p>\n'}]
['https://Stackoverflow.com/questions/65865', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4234/']