lcpan tips 010: Updating your installed Perl modules

About this series: a collection of short, daily blog posts about lcpan tips/recipes. Some posts will also end up in the upcoming App::lcpan::Manual::Cookbook POD to be included in the App-lcpan distribution.

About lcpan: an application to download and index a mini CPAN mirror on your local filesystem, so in effect you will have something like your own CPAN with a command-line tool (or perl API) to query and extract information from your mirror. I find it perfect for my own personal use when working offline.

The cpan-outdated script (or its faster variant cpan-outdated-coro) can compare the version of installed CPAN modules against the version that is indexed in modules/02packages.details.txt.gz file in a CPAN mirror. If your local CPAN mirror is sufficiently up to date (i.e. you have just or quite recently updated it using lcpan update), you can use your local CPAN mirror for this purpose. This can be a bit faster than using a CPAN mirror on the Internet:

% time cpan-outdated-coro

real    0m14.681s
user    0m7.664s
sys     0m0.284s

% time cpan-outdated-coro --mirror file:/home/perlancar/cpan

real    0m8.030s
user    0m7.464s
sys     0m0.196s

The saving is basically just from not having to download the (currently ~1.7MB) modules/02packages.details.txt.gz file.

What can give you more saving is the installation part, because each of the release file is also already available on your local filesystem.

% cpan-outdated-coro --mirror file:/home/perlancar/cpan | cpanm -n --mirror file:/home/perlancar/cpan --mirror-only

Using cpm can be even faster:

% cpan-outdated-coro -p --mirror file:/home/perlancar/cpan | xargs cpm install --mirror file:/home/perlancar/cpan

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s