powerman has asked for the wisdom of the Perl Monks concerning the following question:

Probably I'm too stupid and miss something elementary, but I unable to find a way how to automatically install a bunch of perl modules.

I know about CPAN.pm, of course, and about CPANPLUS.pm too. I've tested both, and looks like they unable to work correctly in some cases. For example, after reading PerlBP book I try to install Smart::Comments module. Both CPAN and CPANPLUS try to install very old 0.01 version (by Autrijus Tang?) instead of last version 1.0.1 by Damian Conway. That version was released 25 May 2005 - enough time ago to update any possible cached databases used by CPAN/CPANPLUS..?

I just don't wanna reinvent that wheel by developing one more tool for this task!

Features I need from that tool are:

All these features doesn't sounds like my unique need, so is tool with these features already exists?

update: One more required feature is:

Replies are listed 'Best First'.
Re: howto install modules
by randyk (Parson) on Oct 10, 2005 at 21:42 UTC

    Regarding the issue of Smart-Comments, the CPAN.pm shell reports

    Module id = Smart::Comments CPAN_USERID AUTRIJUS (Autrijus Tang <autrijus@autrijus.org>) CPAN_VERSION 0.01 CPAN_FILE A/AU/AUTRIJUS/Smart-Comments-0.01.tar.gz INST_FILE (not installed)
    which indicates that the CPAN/PAUSE indices associate Smart::Comments with Autrijus Tang (note - the reported CPAN_FILE isn't available on CPAN). Most likely the reason that DCONWAY/Smart-Comments-1.0.1.tar.gz isn't reported is that ownership of Smart::Comments hasn't been transferred to Damian Conway, or a co-ownership hasn't been established.

    Within the CPAN/CPLANPLUS shells you can always specify a specific distribution to install:

    cpan> install DCONWAY/Smart-Comments-1.0.1.tar.gz
    if you want to do so for a version other than that that the CPAN/PAUSE indices associate a particular module with.

      Thanks for example how to install Conway's version.

      But I still see a problem: it's not obvious way to install just last version of Smart::Comments - to use CPAN.pm this way I first should hit this issue and found author and last version for needed modules manually... this mean CPAN.pm doesn't work in right way and don't do it's primary task (automatically install needed module from CPAN). This mean CPAN.pm and CPANPLUS.pm are not reliable tools. :-(

      I just did some reasearch on this topic and found this:

      • module lists in /by-module/ and /by-authors/id/ differ:
        http://www.cpan.org/modules/by-authors/id/
        contain 26837 modules
        http://www.cpan.org/modules/by-module/
        contain 22012 modules
        plus there 680 modules in /by-module/ which isn't exists in /by-authors/id/!
      • interesting, by I don't found Smart::Comments neither on www.cpan.org in /A/AU/AUTRIJUS/ nor on first CPAN mirror I try (cpan.online.bg)! I wonder from where CPAN.pm downloaded it and found it use another mirror (http://no-more.kiev.ua/CPAN/) which contain a LOT of files which isn't exists on both previous sites (probably admin of this mirror forget to configure deletion of files).
      This in turn mean CPAN.pm not only try to install incorrect version, but also it found incorrectly configured mirror to download file deleted from main CPAN site... this sounds like sabotage! :-)))

      If we forget for a minute about differences between /by-module/ and /by-authors/id/ and decide what /id/ always contain mostly up-to-date modules, then why not just download listings of all subdirectories in /id/ to get correct and reliable list of modules? I've just did this: current size of all downloaded listings (in html) is 18MB, gzip'ed size is 1.2MB (I hope cpan.org's website has mod_gzip installed and all these listings was downloading gzip'ed). I don't see why CPAN.pm don't download these 1.2MB - it's not too much even on 33.6 Kbps modem! If cpan.org will run simple cron-script once per day which will prepare list of all modules in single .txt file, then this file size will be 900KB or even 167KB gzip'ed.

      So, you see, it isn't too complex to make this task reliable. And, you see, CPAN.pm and CPANPLUS.pm doesn't reliable tools. So, is there reliable tool for this task? Or we should reinvent this wheel one more time? :-(

        You're right that some mirrors contain more files than others, and it's probably a configuration issue; for rsync, for example, one would have to enable the --delete flag.

        It's important to distinguish the CPAN.pm/CPANPLUS.pm tools from the CPAN/PAUSE indices living under $CPAN/authors/ and $CPAN/modules/; the tools are just following what's in the indices, and so aren't "broken" in this respect. As you say, it would be possible to go through all distributions on CPAN, extract out the included modules, and make up a set of indices containing the latest versions, irrespective of who the owner is according to the CPAN/PAUSE indices (search.cpan.org does this, to an extent). However, using such a set of indices to install a module with CPAN/CPANPLUS would break the fundamental assumption of unique module names, and would lead to a situation whereby, for example, one author can overwrite another author's module just by uploading a later version to CPAN. There are plans in perl6 to address this - see, for example, CPAN, Perl6, and module versioning - but for now, module ownership/co-ownership is a safeguard put in place to prevent such a situation.

Re: howto install modules
by marto (Cardinal) on Oct 10, 2005 at 20:52 UTC
Re: howto install modules
by mulander (Monk) on Oct 10, 2005 at 21:19 UTC
    Hi, check out:
    1. perldoc cpan 2. perldoc ppm 3. perl -MCPAN -e shell The second one if you are using ActivePerl on Windows.
    You can find it all documented in perldoc so I'll just point out some quick install tips for them:

    1.
    cpan -i WWW::Mechanize
    type this in your command line and it will try to install supplied module. It install the modules needed by this one also.

    2.
    type in ppm in your cmd.exe and wait for it to load.
    You will then see something simmilar to a command line first try searching for your module in avaible repositories ( if you want more repositories install PPM::Repositories ).
    ppm> s PPM::Repositories # this will search for PPM::Repositories mod +ule in active repositories. Searching in Active Repositories # you will get a simmilar list to this one 1. PPM-Repositories [0.11] PPM-Repositories 2. PPM-Repositories [0.11] 3. PPM-Repositories [0.11] PPM-Repositories 4. PPM-Repositories [0.04] PPM-Repositories 5. PPM-Repositories [0.04] PPM-Repositories 6. PPM-Repositories [0.04] PPM-Repositories 7. PPM-Repositories [0.04] PPM-Repositories ppm> desc 1 # get description of the first result ==================== Package 1: Name: PPM-Repositories Version: 0.11 Author: D. H. (crazyinsomniac@yahoo.com) Title: PPM-Repositories Abstract: a list of all *known* ppm package repositories Location: ActiveState PPM2 Repository Available Platforms: 1. MSWin32-x86-multi-thread-5.8 ==================== # install the module ppm> i PPM::Repositories 1 # install the 1st package
    No all you have to do is wait, if there is a module dependency the needed modules will also be installed.

    3.
    I won't tell you much about the shell interface as it is mostly used on linux/unix machines and I have none shell acc. at this moment. When run the first time you will have to set some stuff like your c compiler and archive applications but the default settings are usually good.
    type in perl -MCPAN -e shell and wait for it to load, configure it and you can use it almost exactly as ppm use s module::name to search for a module and i module::name to install it, I think it only checks CPAN repositorie so you do not have to choose what package to install ( but you will have to confirm that you want to install the modules needed by the one you want )

    I know this is not much help but I hope it will throw some light on how it can be done, for more information check the tutorial section of perlmonks.org and perldoc.