Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

perlbrew: moving to a new perl with all current modules

by zgrim (Friar)
on Jun 13, 2012 at 00:26 UTC ( #975893=perlmeditation: print w/ replies, xml ) Need Help??

Given a perlbrew + cpanm setup (which now I can not possibly imagine my toolbox without), a quick dirty/useful way to switch perls and restore all modules in minutes - without an elaborate/proper @INC scan - is to use perllocal:

1. Gather:

perldoc -t perllocal | perl -lane'/"Module"/ && print $F[-1]' | sort - +u >/tmp/pms

2. Switch:

perlbrew switch perl-5.42.0
+
cpanm -v </tmp/pms &>>/tmp/inst.log & tail -f /tmp/inst.log
Update: moritz++ for the list argument reminder and kcott++ for the logfile suggestion. Prev. was
cat /tmp/pms | while read module ; do cpanm -v $module ; done
(yes, I prefer the useless cat :) - I like the award!)


--
perl -MLWP::Simple -e'print$_[rand(split(q.%%\n., get(q=http://cpan.org/misc/japh=)))]'

Comment on perlbrew: moving to a new perl with all current modules
Select or Download Code
Re: perlbrew: moving to a new perl with all current modules
by kcott (Abbot) on Jun 13, 2012 at 06:01 UTC

    ++ I liked the overall technique you've used here. Here's a few thoughts:

    "... restore all modules in minutes ... " - I question the time you estimate here; although, as I don't use cpanm, I'm happy to be advised otherwise.

    Is there a reason for sort in the 1st line? I might have used: s/sort -u/uniq/.

    The output from the 3rd line is likely to be quite lengthy. Consider adding  > /tmp/pms_out 2>&1. You can use tail -f if you want to view the output and you have a full history if anything goes wrong.

    Update: s/is you want/if you want/

    -- Ken

      Yes, the time estimate might be optimistic, depends on many things, of course, module list size, disk & network speed, cpu, etc. The important thing is it is non-interactive, you don't have to sit around answering author questions :) (eg: just hitting Enter some 2h later - when coming back to it - to a "stuck" (Y/n)) so in the end it just might feel faster, given you are free to do other important things (eg: coffee/tea) meanwhile. Skipping tests makes it way faster (cpanm -n), but let noone hear us, it's frowned upon with good reason. :)

      I prefer the sort for two small reasons, 1. eases a bit the visual inspection before install, and 2. upon progress inspection you might wanna know which letter it's at, has an irrational but human "progress bar" feel to it. :)

      Sure, you can output to some log and tail it,

      cpanm -v </tmp/pms &>>/tmp/inst.log & tail -f /tmp/inst.log
      , but i usually just hit M-s error in my urxvtc.


      --
      perl -MLWP::Simple -e'print$_[rand(split(q.%%\n., get(q=http://cpan.org/misc/japh=)))]'
Re: perlbrew: moving to a new perl with all current modules
by moritz (Cardinal) on Jun 13, 2012 at 08:02 UTC

    Or even cat /tmp/pms | xargs cpanm, since cpanm accept multiple modules to install on its command line.

    I also have a local CPAN mirror set up with CPAN::Mini, which greatly reduces installation time of modules. (And no, for bigger installations that still takes more than a minute, but the manual effort is just a minute).

      Some operating systems (e.g. Linux) place an arbitrary limit on the length (in bytes) of the argument list passed to a process.

      See Linux ARG_MAX.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://975893]
Approved by kcott
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-09-30 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (363 votes), past polls