http://www.perlmonks.org?node_id=897506

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

perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)' is an easy way to update your perl modules.

But not practically if you only have a user account and the sysadmins are reluctant to update perl modules.

Ok, you do it in your homedir which works fine. But at one point you want to update your locally installed perlmodules.

How would you modify the line above so that only your extra modules will be checked. And no, i didn't have tracked all modules i've installed.

Any idea ?

  • Comment on How to effectively update perl modules which are installed in my homedir
  • Download Code

Replies are listed 'Best First'.
Re: How to effectively update perl modules which are installed in my homedir
by sundialsvc4 (Abbot) on Apr 05, 2011 at 17:35 UTC

    Start by reading the documentation for cpan, and its various configuration options.   Then, search here (and on Google) for “Perl as a non-root user.”

    The best and safest way to build your own configuration, in my opinion, is to not attempt to “update” the Perl modules that are set up by your local configuration, but rather to use facilities like the PERL5LIB environment-variable and the use lib statement to “supersede” them.   You do this by arranging for CPAN to install modules into a directory of your choosing, then putting that directory ahead of the default dirs in the @INC list.   (Which you can examine by the command, perl -V (with a capital “V”).

    There a couple of common situations where you would choose to do this.   One is when you’re running a Linux distro that uses Perl for its system-administration and package-installation tools:   you probably don’t want to disrupt those unless you want to learn a lot about Linux in a big hurry.   The other is when you’re running a Perl web-site at a shared hosting facility.   Not only is it impossible to update their system-wide libraries, but you don’t want to be in full control of what your (customer’s | employer’s) website actually uses and sees.

Re: How to effectively update perl modules which are installed in my homedir
by FunkyMonk (Chancellor) on Apr 05, 2011 at 21:07 UTC
    Search your homedir for a file called perllocal.pod. It lists all the packages you've installed. Assuming, of course, that your toolchain supports perllocal (cpan and cpanp both do, but I don't know about others).

    The section for one installed module looks like...

    =head2 Thu Feb 17 19:27:04 2011: C<Module> L<DBI|DBI> =over 4 =item * C<installed into: /usr/local/lib/perl5/site_perl/5.12.3> =item * C<LINKTYPE: dynamic> =item * C<VERSION: 1.616> =item * C<EXE_FILES: dbiproxy dbiprof dbilogstrip> =back

Re: How to effectively update perl modules which are installed in my homedir
by Anonymous Monk on Apr 05, 2011 at 13:40 UTC
     
    $ perldoc cpan |grep -i update
     
    $ perldoc cpan |grep -i upgrade
     
    $ perldoc cpan |grep -i date
            Show the module details. This prints one line for each out-of-date
        -O Show the out-of-date modules.
        up-to-date and Changes features.
      This option is relative new ? At least cpan shell v1.7602 does not know about it.
      
      But anyway. I think this will print ALL modules which needs to be updated and not the ones which are in my local homedir ? (Couldn't test it yet.)
        It will do what it says it will do, print you a list, which you can iterate over, then filter by location
        $ perl -MCGI -le " print for grep /CGI.pm/, values %INC" C:/perl/5.12.2/lib/CGI.pm $ perldoc -l CGI C:\perl\5.12.2\lib\CGI.pm
Re: How to effectively update perl modules which are installed in my homedir
by j1n3l0 (Friar) on Apr 05, 2011 at 16:14 UTC
    You may consider looking up the options on CPANPLUS. I think the one you need is the o option. Or you could investigate cpan-outdated which in combination with cpan does what you want.

    Smoothie, smoothie, hundre prosent naturlig!
Re: How to effectively update perl modules which are installed in my homedir
by adamcrussell (Hermit) on Apr 05, 2011 at 19:11 UTC
    If you use local-lib then this is done for you be default, I believe. cpan.uwinnipeg.ca/htdocs/local-lib/local/lib.pm.html
    <jc> Why do people persist in asking me stupid questions?
    <Petruchio> <insert mutually recursive response>
    --an exchange from #perlmonks on irc.slashnet.org(2 March 2009 1345 EST)
Re: How to effectively update perl modules which are installed in my homedir
by stonecolddevin (Parson) on Apr 05, 2011 at 20:55 UTC

    local::lib is definitely the way to go with this, and you could combine it with App::cpanoutdated like this: cpan-outdated|cpanm, on a *nix system.

    Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past