About this series: A collection of short 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. First article is here. See the whole series.
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.
A previous tip shares this recipe to install a CPAN distribution by mentioning its script name:
% cpanm -n `lcpan script2mod pm-uninstall`
Since then, two convenient utilities have been added: cpanm-script and lcpanm-script. The first one is a thin wrapper over cpanm, while the second one is a thin wrapper over lcpanm (which is itself a thin wrapper over cpanm). They basically work the same as the above recipe: given a script name, look up the distribution name the script is included in then convert it to module name, and then pass it to cpanm.
Being simple thin wrappers, {,l}cpanm-script do not add command-line options of their own but simply convert the script name to module name and pass the rest of the options. For example, when a script with the same name exists in multiple distributions (e.g. hangman) only the first one is chosen to be installed. If you want to install all of them, you can use:
% cpanm -n `lcpan script2mod pm-uninstall`
However, these scripts offer another convenience: tab completion.
% lcpanm-script - % lcpanm-script hang
It’s better to enter a few characters first to prevent the completion routine from trying to retrieve the whole list of scripts on CPAN.