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

坚强是说给别人听的谎言 提交于 2020-01-23 11:38:45

问题


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

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4008964/how-can-i-safely-compile-a-perl-5-12-module-for-perl-5-8-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!