Perl: Can't install/use CPAN modules - perl

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

Related

perlbrew: installing a perl module locally

I've got perlbrew installed on OS X fine, and can install Perl modules from CPAN, using 'cpanm' no problem.
But, now I'm attempting to install a Perl module provided from a software vendor, and that PM is not on CPAN - you download it from their application and install it "locally".
I'm not sure how to accomplish this with perlbrew ?
The documentation states to do a direct install, download the tar.gz file, extract it, then:
cd Infoblox-xxxxxxx/
perl Makefile.PL
make
make install
But if I do this, I guess it will install it for the OS Perl version, not my perlbrew install.
The other option mentioned is to create a local CPAN site and add the appliance URL (to grab the Perl module) to the list of sites. Is this possible with perlbrew ?
Thanks !
cd Infoblox-xxxxxxx/
perl Makefile.PL
make
make install
But if I do this, I guess it will install it for the OS Perl version, not my perlbrew install.
If you are using perlbrew to select your perl, it should install in the appropriate location for the perl you selected.
which perl will tell you which perl you are using.
If you want to use a specific perl without leaving things to perlbrew, you can always invoke the specific perl you want using its full path:
cd Infoblox-xxxxxxx/
~/perl5/.../bin/perl Makefile.PL
make
make install

Unable to install any perl modules because it can't location strict.pm

Hello StackOverflow Community,
I am trying to install a perl module, IO::All. But every time I use CPAN to install many perl modules (including if I run from within cpan "install Build::CPAN") it fails with
Can't locate strict.pm in #INC (#INC contains:
/dev/null/lib/perl5.8-dist/Linux-2.6c2.5-x86_64-64int
/dev/null/lib/perl5.8-dist
/dev/null/lib/perl5.8-dist/Linux-2.6c2.5-x86_64-64int
/dev/null/lib/perl5.8-dist /dev/null/lib/perl5.8-dist .) at Build.PL
line 2.
This has been baffling me for hours. I've googled around and can't seem to find a solution. Running something like
perl -e 'use strict; print "ok"'
Outputs just fine. And the original file I was trying to run, which asks for IO::All uses strict as well. How is strict even missing? Isn't strict part of perl by default? And where is /dev/null? Isn't that a special location where you can pass in stderr/stdout if you don't care about that? I've been pulling my hair out about this for a while. I must be missing something obvious.
This is running on a Rhel5 Virtual Machine Linux-2.6-x86_64 variant.
Your help is much appreciated. Let me know if I need to provide further information.
Thank you,
-Asaf
I have this issue today. I compiled perl 5.14 and install to my home directory ($HOME/perl5.14/).
Because perl5.14 install some minimum perl5 libraries, you have to include the directory into $PERL5LIB=$HOME/perl5.14/usr/local/lib/perl5/5.14.2
Hope this works for you :)
I also suspect that your cpan script is misconfigured. But perl -MCPAN uses the same config, so won't help you.
Installing an alternative CPAN client might help. I'd recommend cpanminus because it's very easy to install. Just run the following command (preferably while logged in as root):
curl -L http://cpanmin.us | perl - App::cpanminus
Now you should have cpanminus, you can use it to install IO::All:
cpanm -S -v IO::All

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

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>

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

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.