How do I update all my CPAN modules to their latest versions? - perl

How do I update all my CPAN modules to their latest versions?

An alternative method to using upgrade from the default CPAN shell is to use cpanminus and cpan-outdated.
These are so easy and nimble to use that I hardly ever go back to CPAN shell. To upgrade all of your modules in one go, the command is:
cpan-outdated -p | cpanm
I recommend you install cpanminus like the docs describe:
curl -L https://cpanmin.us | perl - App::cpanminus
And then install cpan-outdated along with all other CPAN modules using cpanm:
cpanm App::cpanoutdated
BTW: If you are using perlbrew then you will need to repeat this for every Perl you have installed under it.
You can find out more about cpanminus and cpan-outdated at the Github repos here:
https://github.com/miyagawa/cpanminus
https://github.com/tokuhirom/cpan-outdated

An easy way to upgrade all Perl packages (CPAN modules) is the following way:
cpan upgrade /(.*)/
cpan will recognize the regular expression like this and will update/upgrade all packages installed.

For Strawberry Perl, try:
cpan -u

Try perl -MCPAN -e "upgrade /(.\*)/". It works fine for me.

upgrade
BTW there is a help command.

Related

How to install all perl modules at once in Ubuntu

I want to install all available perl modules at once in Ubuntu.
Is such a thing possible?
Instead of installing everything, why not use CPAN::Mini to get them all on your local machine. Then you can install the ones you need when you need them.
As others have said, you probably don't want to.
Many modules are updated more frequently on CPAN than the Ubuntu repos
Some modules aren't in the repos at all.
Many modules will have dependencies you don't need.
If you ever need more than one environment, it's a problem (although to be fair, this is generally a much rarer occurrence with perl than with other ecosystems).
perlbrew and cpanm are lovely and don't require `sudo
It's not a replacement for proper dependency management as if you ever have a distro upgrade, not all packages may be provided next time.
... however, if you're determined, a very straightforward way would be to look at the output of
sudo apt-get search perl | sed -e 's/ - .*//'
... and if it's to your liking, run
sudo apt-get search perl | sed -e 's/ - .*//' | xargs sudo apt-get install
Personally, I'd probably stick a | egrep '-perl' | in there, too before the xargs, as you might get hits based on the description that don't represent actual perl modules.
[Answer based on "Why?" provided in comments]
Based on my personal experience:
Almost all perl modules required for serious development are available as ubuntu/debian packages
e.g. Net::DBus perl package is provided by libnet-dbus-perl ubuntu/debian package.
You may install ubuntu/debian packages and keeping system itself up to date will update your installed perl modules.

Installing PERL CPAN modules in local directory

i have a 1and1 hosting account and would like to install some Perl CPAN modules that are not part of the standard host package. Is it possible to install modules without ROOT access? If so, how do i do that? Thanks for the pointers in advance.
cpanminus is quickly becoming the choice interface for CPAN. It supports installing packages in to the user's home directory.
Its usage is frightening simple. To install the cpanminus package locally:
curl -L http://cpanmin.us | perl - App::cpanminus
To install an arbitrary package:
curl -L http://cpanmin.us | perl - Lingua::Romana::Perligata
Remember to add the user's local library to the PERL5LIB environment variable.
export PERL5LIB=$HOME/perl5/lib/perl5:$PERL5LIB
I would suggest you use perlbrew and install a whole build of Perl in your account, not just modules. Less headaches that way, especially when the provider decides to update the system Perl.
This is an excellent article about installing perl modules as a regular (non-root) user:
Installing Perl Modules as a Non-Root User
For installing modules to a local directory, you can use local::lib.
As already said: local::lib
cpanm --local-lib=~/Program/Perl/Lib Tk

Automatically Install Package-Based Perl Modules in Ubuntu

I would like to install the Perl modules required by a specific Perl script, such as those listed by the perl-depends tool. However, I would like to do that in Ubuntu using the apt-get, meaning installing the modules through the package repository and not through CPAN.
Most similar questions (such as this one) address ways of doing that through CPAN.
Debian-Apt-PM
This will list all packages having perl in them:
sudo apt-cache search perl *
then:
sudo apt-get install pkg_name_in_output

Perl: Can't install/use CPAN modules

I'm trying to code a litte RSS Parser in perl. Just as simple as possible.
To parse a rss feed (e.g. www.rssfeedhomepage.com/rssfeed.xml) I want to use a module from the CPAN Homepage, because it's much easer than create an own one.
But I'm not able to install it. I tryied it using the shell ( "perl -MCPAN -e shell") and manually (unzip, install, make) but it didn't work out. I tried it with severals RSS modules but everytime the same problem. Do you have any ideas?
I'm using ubuntu linux as a VM on Windows 7.
Thanks!
I suggest using the awesome cpanminus tool to install a module from CPAN:
First install cpanminus itself:
$ curl -L http://cpanmin.us | perl - --sudo App::cpanminus
Then install whathever module you want like the following:
$ sudo cpanm Some::Module
cpanminus should work out of the box, it's a zeroconf tool written by Tatsuhiko Miyagawa

How do I install CPAN modules while using perlbrew?

I have started using perlbrew and installed perl-5.12.2.
I understand I need to re-install my CPAN modules, so I switched to my new Perl version (perlbrew switch perl-5.12.2 and hash -r), verified the switch was successful (perl -v) then tried installing some module (File::Copy::Recursive using cpan. However, cpan says `File::Copy::Recursive is up to date (0.38).
When I start a Perl script using this module, it shouts Can't locate File/Copy/Recursive.pm in #INC ... (showing many perl-5.12.2 locations). When I switch back to my 'normal' Perl (perlbrew off) the script runs fine.
Any suggestions? Perhaps CPAN does not work well with perlbrew?
After installing perlbrew you could install cpanm through this command:
perlbrew install-cpanm
Otherwise you will need to install cpanm manually each time you switch your Perl version on perlbrew. With this command just once.
Once installed you can then use cpanm to install the missing module:
cpanm File::Copy::Recursive
Everything should be working fine with "cpan" as well as "cpanm", that is: when switching perl with perlbrew, cpan sees the installed modules of the version you use.
While it's true that cpanm is the recommended tool to use with perlbrew, cpan allows for test reporting so that is what I always use.
How do I install CPAN modules while using perlbrew?
That's how:
perlbrew use <version>
cpan -i <module>