Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Installing modules in old version of perl

by JediWombat (Novice)
on Jul 11, 2018 at 05:23 UTC ( #1218275=perlquestion: print w/replies, xml ) Need Help??

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

Hi gurus,

I'm afraid I don't know a lot about what I'm doing with Perl/CPAN, but essentially, I've got an old Cent5 box that is running perl5.8.8, and I need to install some modules to it, so I can move an existing program to it.

The module I'm trying to install is File::Basename. When I run cpan File::Basename, I get:

The most recent version "2.85" of the module "File::Basename" is part of the perl-5.28.0 distribution. To install that, you need to +run force install File::Basename --or-- install X/XS/XSAWYERX/perl-5.28.0.tar.gz CPAN: Time::HiRes loaded ok (v1.9717)

Now, if I understand the problem (unlikely), it's that CPAN automatically looks for the newest version of any module, rather than the newest module for my current perl. How can I install a version of this module for my current perl, 5.8.8? Or, am I misunderstanding the issue?

I tried using the suggested `force install` command, which seems to have installed perl5.28.0 alongside my existing stuff.

I've tried searching for solutions to this, but it's hard to know what to search for; I get a lot of results for checking version numbers, etc., but nothing that I can find is about installing old modules into older perl versions.

Can someone straighten me out on this, please, and help me learn how to do this properly?

Thanks, Benjamin.

Replies are listed 'Best First'.
Re: Installing modules in old version of perl
by dave_the_m (Monsignor) on Jul 11, 2018 at 06:17 UTC
    File::Basename is part of the base perl distribution even in 5.8.8. So it shouldn't need installing - are you sure it isn't already present? It's possible that CentOS split the distribution into multiple RPMs and the RPM containing Basename hasn't been installed - in which case insatll that RPM using yum

    Dave.

Re: Installing modules in old version of perl
by marto (Archbishop) on Jul 11, 2018 at 08:53 UTC

    If you're using the system perl, use your systems package management tool to install modules. Some distros split perl into various packages, often reomving core stuff, while still calling it 'perl', which causes issues/confusion.

    corelist File::Basename will tell you that File::Basename has been a core module since perl v5. corelist -a File::Basename will expand on this.

    "I tried using the suggested `force install` command, which seems to have installed perl5.28.0 alongside my existing stuff."

    If you did this with sufficient privileges you may have just you may have replaced your perl v5.8.8 with v5.28.0. perl -v will show you.

    I find it simpler just to leave the system perl alone, installing my own version elsewhere on the system.

Re: Installing modules in old version of perl
by haj (Hermit) on Jul 11, 2018 at 06:16 UTC

    Hello Benjamin,

    You are correct: CPAN looks for the newest version unless told otherwise. However, before going into your actual question, a few hints:

    • File::Basename is part of the Perl distribution, so it should not be necessary to install it from CPAN.
    • If you need a Perl module corresponding to your Perl version, you can also check whether it is available as a package from the Cent5 repository.
    • Quite often, the current version of a module from CPAN will work just fine with Perl 5.8.8. You can just try: If it doesn't, you should get an error message during the installation.

    Should you ever need to install an older version from CPAN, there's a recipe on https://www.perl.com/article/4/2013/3/27/How-to-install-a-specific-version-of-a-Perl-module-with-CPAN/.

Re: Installing modules in old version of perl
by Anonymous Monk on Jul 11, 2018 at 06:05 UTC

    Seems like File::Basename v2.85 is not available as a separate package, only as part of newer perl. You could file a bug report for it to be available separately too (as was suggested to me when similar thing happened to File::Stat; I switched to File::stat instead).

    Or, you could (manually) copy the source of File/Basename.pm v2.85 somewhere in @INC (list of module search paths) of old perl. Or, you could try installing an older version of the module which is available separately of perl, if available at all.

Re: Installing modules in old version of perl
by Anonymous Monk on Jul 11, 2018 at 14:36 UTC
    If you are using a Perl that was installed using RPMs, you should first look for another RPM package that contains the functionality you are looking for, and update the software that way.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1218275]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2019-07-15 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?