开发者

How can I safely compile a Perl 5.12 module for Perl 5.8.9?

开发者 https://www.devze.com 2023-01-21 13:08 出处:网络
I want to install File::Fetch, which is a core module in Perl 5.12, in my Perl 5.8.9. In general, I want to compile and install future-dated modules in my back-dated Perl because I cannot upgrade my P

I want to install File::Fetch, which is a core module in Perl 5.12, in my Perl 5.8.9. In general, I want to compile and install future-dated modules in my back-dated Perl because I cannot upgrade my Perl.

So I downloaded the module and also its dependencies. It's quite painful following the dependency tree but I'm more concerned about the fact that some of them are 开发者_开发知识库core modules. If I install these, my Perl 5.8.9 core will have patches from 5.12.

My question is how I can know whether I can safely install the future-dated modules, especially the core modules. Is there a tutorial for this purpose of testing backwardcompatability in Perl?

EDIT:

My module is dual lifed, but I cannot compile it using cpan. It said my FTPsite.yaml has a bad element. However, I followed the dependencies in the modules' META files, and I could compiled the module. Is this one of the odd bits with cpan? Thank you.

I cannot recreate the issue after I installed all those dependencies manually. But here is the error:

cpan[5]> install File::Fetch
Running install for module 'File::Fetch'
Running make for B/BI/BINGOS/File-Fetch-0.24.tar.gz
CPAN: Digest::SHA loaded ok (v5.48)
CPAN: Time::HiRes loaded ok (v1.9715)
CPAN: YAML loaded ok (v0.72)
Alert: While trying to 'parse' YAML file
 '/Users/martin/.cpan/FTPstats.yml'
with 'YAML' the following error was encountered:
  YAML Error: Invalid element in map
   Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
   Line: 3
   Document: 1
 at /opt/local/lib/perl5/site_perl/5.8.9/YAML.pm line 36


If the module is available separately (i.e. "dual-lifed"), as both a standalone distribution and inside core Perl, then the standalone version is safe to install on an earlier Perl, assuming its Makefile allows it. That is, if you can do cpan <Module> and it builds and tests without errors, then you are good.

The only problem is if a module is not dual-lifed, which I opined about in this question -- which is where you are likely S.O.L.


If a perl core module is also available separately, that means that it is intended to work on older perls (unless it explicitly requires some version of perl), and if it doesn't, that's a bug.

That said, 5.10 was released almost three years ago, and you are going to start seeing more and more problems using newer modules with older versions of perl.

cpan or cpanplus will handle dependencies for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号