staszeko has asked for the wisdom of the Perl Monks concerning the following question:

I have a problem downloading Perl module 'Log::Log4Perl' using CPAN on Linux CentOS.

When I execute command
# cpan -i Perl::Log4Perl

I get error
Can't locate object method "data" via package "CPAN::Modulelist" (perhaps you forgot to load "CPAN::Modulelist"?)

I loaded newer indicies using command
cpan> reload index

then loaded CPAN.pm again
cpan> reload cpan

then removed entire directory '.cpan' including file 'Config.pm', but this did not solve the problem.

I would much appreciate any pointers that could lead me to a successful resolution.

cpan script version 1.03
CPAN.pm version 1.7602

Linux 2.6.18-308.13.1.el5PAE #1 SMP Thu Jul 26 06:08:24 EDT 2012 i686 i386 GNU/Linux

Replies are listed 'Best First'.
Re: CPAN install module error
by cbeckley (Curate) on Mar 23, 2017 at 03:03 UTC

    I just ran into this.
    On CentOS, and other RedHat derivitives, it is recommended that you not install modules via CPAN, but rather with yum.
    This is assuming you are adding modules to system Perl.

    First you want to install the EPEL, as root:

    # yum install epel-release

    These three commands tell you what exists, what is installed, and what is available:

    # yum list all # yum list installed # yum list available

    Perl modules are prefixed with "perl-"

    If you find the module you want from the available list, you can install it via:

    # yum install -y perl-Module-I-Want

    Note: Module::I::Want becomes perl-Module-I-Want via yum.

    This all assumes that
    a) you are root, and
    b) you want to update system Perl

    If either of these are not true you might want to investigate https://perlbrew.pl/
    which I have not used, but was brought to my attention by mr_mischief, and has been recommended by several other monks.

    Hope that helps,
    cbeckley

    Update: Log::Log4Perl is available in the EPEL.

      First, thanks to all that replied - I haven't expected so quick response.

      Second, my apology for not explaining, why I have to stick with older version of CPAN.pm (1.7602). This installation runs on a machine which belongs to a large, international corporation. Although I do have a root access, I need to obtain business approval before any update, which practically is almost impossible.

      So, using yum as suggested by checkley seemed to be a good choice. But then I run into number of missing dependencies and when I tried to solve first of them
      # yum install -y perl-Date-Format

      I got message
      No package perl-Date-Format available.

        Cool. Just contact your supervisor of tech support and have them solve it
Re: CPAN install module error
by hippo (Archbishop) on Mar 23, 2017 at 09:30 UTC
    Linux 2.6.18-308.13.1.el5PAE

    I have bad news for you. That's CentOS 5 which is hitting EOL a week tomorrow. You would do much better by switching to some other operating system with support extending beyond this month.

    If you want to install modules aside from those already available via yum then the cpan tool is not the only option. You may also install the modules by hand which IME gives you better control over the process.

    The actual problem you are facing, however, is that you are using the wrong module name. Compare

    I have a problem downloading Perl module 'Log::Log4Perl'

    with

    # cpan -i Perl::Log4Perl

    Spot the difference?

      Actually, this was a typo in my post.

      Below is the full output of the command.

      # cpan -i Log::Log4perl CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Database was generated on Thu, 16 Jul 2009 15:27:04 GMT Going to read /root/.cpan/sources/authors/01mailrc.txt.gz CPAN: Compress::Zlib loaded ok Going to read /root/.cpan/sources/modules/02packages.details.txt.gz Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz do +es not contain a Line-Count header. Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to happen. Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz do +es not contain a Last-Updated header. Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to happen. Going to read /root/.cpan/sources/modules/03modlist.data.gz Can't locate object method "data" via package "CPAN::Modulelist" (perh +aps you forgot to load "CPAN::Modulelist"?) at (eval 20) line 1, <FH> + line 20. at /usr/lib/perl5/5.8.8/CPAN.pm line 3405 CPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/mo +dules/03modlist.data.gz') called at /usr/lib/perl5/5.8.8/CPAN.pm line + 3128 CPAN::Index::reload('CPAN::Index') called at /usr/lib/perl5/5. +8.8/CPAN.pm line 675 CPAN::exists('CPAN=HASH(0x9c77f50)', 'CPAN::Module', 'Log::Log +4perl') called at /usr/lib/perl5/5.8.8/CPAN.pm line 1841 CPAN::Shell::expandany('CPAN::Shell', 'Log::Log4perl') called +at /usr/lib/perl5/5.8.8/CPAN.pm line 2077 CPAN::Shell::rematein('CPAN::Shell', 'install', 'Log::Log4perl +') called at /usr/lib/perl5/5.8.8/CPAN.pm line 2164 CPAN::Shell::install('CPAN::Shell', 'Log::Log4perl') called at + /usr/bin/cpan line 202

        Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz do +es not contain a Line-Count header. Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to happen. Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz do +es not contain a Last-Updated header. Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to happen.

        So what did you find when you checked the validity of the index file by comparing it to more than one CPAN mirror?

        Actually, this was a typo in my post. Below is the full output of the command.

        Hi, this changes nothing

Re: CPAN install module error
by Anonymous Monk on Mar 23, 2017 at 01:25 UTC

    I would much appreciate any pointers that could lead me to a successful resolution.

    Use a something from this decade, perl 5.8.8 , CPAN 1.7602 are from a decade ago

    this probably means you're using some system perl, its better not to mess with it , leave that to your operating system

    install another perl, for example in your home directory or something

      Although I agree with this, mostly, it would be nice, AnonyMonk, if you could put up such responsible answers in a bit more reasonable way.

        Although I agree with this, mostly, it would be nice, AnonyMonk, if you could put up such responsible answers in a bit more reasonable way.

        Say what?