Perl: How do I install Perl modules? eg. Installing LWP module for Perl.

The easiest way to install Perl modules is by installing them through “shell”. Let us say that you are trying to install very common module called: LWP

You can test to see if you have LWP installed by typing:
perl -MLWP -le "print(LWP->VERSION)"
If you get something like: Can’t locate LWP.pm in @INC means that you don’t have it installed. To install LWP, type:
perl -MCPAN -eshell
NOTE: most times it is okey for you to accept default answers to questions cpan asks.
You can read through cpan help by typing “h” without the quotes at cpan> prompt.
To continue installing LWP, type:
install Bundle::LWP
After few questions, and some text scrolling, you will have LWP installed. If for some reason you don’t want to do it this way, you can always obtain source for the module you are trying to install and build it from source files. You can obtain these files from CPAN site

22 thoughts on “Perl: How do I install Perl modules? eg. Installing LWP module for Perl.

  1. adil ismael

    getting error by intalling perl module
    new to linux cpan

    # perl -MCPAN -eshell
    Terminal does not support AddHistory.

    cpan shell — CPAN exploration and modules installation (v1.7602)
    ReadLine support available (try ‘install Bundle::CPAN’)

    cpan> install Bundle::LWP
    CPAN: Storable loaded ok
    Going to read /usr/src/perll/asterisk-perl-0.05/yes/sources/authors/01mailrc.txt.gz
    yes: invalid option — –
    Try `yes –help’ for more information.
    Going to read /usr/src/perll/asterisk-perl-0.05/yes/sources/modules/02packages.details.txt.gz
    yes: invalid option — –
    Try `yes –help’ for more information.
    Warning: Your /usr/src/perll/asterisk-perl-0.05/yes/sources/modules/02packages.details.txt.gz does not contain a Line-Count header.
    Please check the validity of the index file by comparing it to more
    than one CPAN mirror. I’ll continue but problems seem likely to
    happen.
    Warning: Your /usr/src/perll/asterisk-perl-0.05/yes/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header.
    Please check the validity of the index file by comparing it to more
    than one CPAN mirror. I’ll continue but problems seem likely to
    happen.
    Going to read /usr/src/perll/asterisk-perl-0.05/yes/sources/modules/03modlist.data.gz
    yes: invalid option — –
    Try `yes –help’ for more information.
    Can’t locate object method “data” via package “CPAN::Modulelist” (perhaps you forgot to load “CPAN::Modulelist”?) at (eval 20) line 1.
    at /usr/lib/perl5/5.8.8/CPAN.pm line 3405
    CPAN::Index::rd_modlist(‘CPAN::Index’, ‘/usr/src/perll/asterisk-perl-0.05/yes/sources/modules/03modli…’) called at /usr/lib/perl5/5.8.8/CPAN.pm line 3128
    CPAN::Index::reload(‘CPAN::Index’) called at /usr/lib/perl5/5.8.8/CPAN.pm line 785
    CPAN::instance(‘CPAN=HASH(0x89a12bc)’, ‘CPAN::Bundle’, ‘Bundle::DBI’) called at /usr/lib/perl5/5.8.8/CPAN.pm line 1427
    CPAN::Shell::local_bundles(‘CPAN::Shell’) called at /usr/lib/perl5/5.8.8/CPAN.pm line 1835
    CPAN::Shell::expandany(‘CPAN::Shell’, ‘Bundle::LWP’) called at /usr/lib/perl5/5.8.8/CPAN.pm line 2077
    CPAN::Shell::rematein(‘CPAN::Shell’, ‘install’, ‘Bundle::LWP’) called at /usr/lib/perl5/5.8.8/CPAN.pm line 2164
    CPAN::Shell::install(‘CPAN::Shell’, ‘Bundle::LWP’) called at /usr/lib/perl5/5.8.8/CPAN.pm line 201
    eval {…} called at /usr/lib/perl5/5.8.8/CPAN.pm line 201
    CPAN::shell() called at -e line 1

    cpan>

    don’t know what to do
    will anybody guide

  2. Pingback: MySQL: How do you install innotop to monitor innodb in real time? | Technology: Learn and Share

  3. Abhishek Singh

    I’ve the same problem:

    Going to read /root/.cpan/sources/authors/01mailrc.txt.gz
    Going to read /root/.cpan/sources/modules/02packages.details.txt.gz
    Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Line-Count header.
    Please check the validity of the index file by comparing it to more
    than one CPAN mirror. I’ll continue but problems seem likely to
    happen.
    Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header.
    Please check the validity of the index file by comparing it to more
    than one CPAN mirror. I’ll continue but problems seem likely to
    happen.
    Going to read /root/.cpan/sources/modules/03modlist.data.gz
    Can’t locate object method “data” via package “CPAN::Modulelist” (perhaps you forgot to load “CPAN::Modulelist”?) at (eval 13) line 1.
    at /usr/lib/perl5/5.8.5/CPAN.pm line 3406
    CPAN::Index::rd_modlist(‘CPAN::Index’, ‘/root/.cpan/sources/modules/03modlist.data.gz’) called at /usr/lib/perl5/5.8.5/CPAN.pm line 3129
    CPAN::Index::reload(‘CPAN::Index’) called at /usr/lib/perl5/5.8.5/CPAN.pm line 786
    CPAN::instance(‘CPAN=HASH(0xa3e8604)’, ‘CPAN::Bundle’, ‘Bundle::Apache2’) called at /usr/lib/perl5/5.8.5/CPAN.pm line 1428
    CPAN::Shell::local_bundles(‘CPAN::Shell’) called at /usr/lib/perl5/5.8.5/CPAN.pm line 1836
    CPAN::Shell::expandany(‘CPAN::Shell’, ‘Bundle::CPAN’) called at /usr/lib/perl5/5.8.5/CPAN.pm line 2078
    CPAN::Shell::rematein(‘CPAN::Shell’, ‘install’, ‘Bundle::CPAN’) called at /usr/lib/perl5/5.8.5/CPAN.pm line 2165
    CPAN::Shell::install(‘CPAN::Shell’, ‘Bundle::CPAN’) called at /usr/lib/perl5/5.8.5/CPAN.pm line 201
    eval {…} called at /usr/lib/perl5/5.8.5/CPAN.pm line 201
    CPAN::shell() called at /usr/bin/cpan line 193

    I’m using RHEL 4. Performing cpan -i Bundle::CPAN does not solve the problem, rather reiterates it.

    What could be the solution. Thanks in advance.

  4. Ben

    tried installing Bundle::LWP

    got this:

    Going to read /home/admin/.cpan/sources/authors/01mailrc.txt.gz
    Could not pipe[/bin/gzip –decompress –stdout /home/admin/.cpan/sources/authors/01mailrc.txt.gz |]: Cannot allocate memory at (eval 20) line 5727, line 9.

    Any ideas?

  5. BestLatosha

    I have noticed you don’t monetize your site, don’t waste your traffic, you
    can earn additional cash every month because you’ve got hi quality content.
    If you want to know how to make extra $$$, search for: Ercannou’s essential adsense
    alternative

  6. golden goose sneakers

    Thank you for each of your labor on this web page. My mom really loves getting into investigations and it’s easy to understand why. I notice all regarding the lively mode you render powerful guidelines through this web blog and increase participation from people on this subject matter so our girl has always been understanding a great deal. Take pleasure in the rest of the new year. You’re the one performing a good job.

  7. air jordan

    I really wanted to send a simple comment to be able to express gratitude to you for all the stunning guides you are sharing here. My particularly long internet research has at the end of the day been honored with reliable knowledge to write about with my neighbours. I would repeat that we readers are very much lucky to dwell in a very good website with many perfect people with helpful points. I feel quite blessed to have come across your entire website page and look forward to so many more excellent minutes reading here. Thank you once again for everything.

  8. dior glasses

    I wanted to post you a very little remark in order to say thanks over again over the beautiful techniques you’ve featured at this time. It is certainly tremendously open-handed of people like you to make easily precisely what a few people might have distributed for an ebook in order to make some dough for themselves, specifically now that you could possibly have done it in case you desired. Those good ideas in addition acted like the fantastic way to comprehend someone else have a similar fervor just like my personal own to understand much more on the topic of this issue. I believe there are some more pleasurable times up front for individuals who discover your blog.

  9. adidas nmd r1

    I must show some thanks to you just for bailing me out of this particular dilemma. Because of exploring throughout the online world and seeing views which are not productive, I thought my life was over. Existing minus the answers to the issues you’ve fixed by way of the guide is a serious case, as well as the ones which may have adversely affected my career if I hadn’t noticed your blog post. Your good knowledge and kindness in controlling all the things was important. I am not sure what I would’ve done if I hadn’t come across such a point like this. I am able to at this point relish my future. Thank you so much for this expert and results-oriented help. I will not think twice to propose the blog to anybody who should get guidelines on this matter.

Leave a Reply

Your email address will not be published. Required fields are marked *