所有 Perl 版本都支持旧模块吗?
我在所有服务器上安装了 Perl 5.8,并希望使用 DBI 和 DBD::Oracle 模块来访问我们的数据库。我主要担心的是,对于较新版本的 perl,DBI 和 DBD 模块将停止与 5.8 一起使用。然后我必须将每台服务器升级到最新的 perl 版本。
我的问题是,随着 perl 本身成为更高的版本并且为它们开发模块,它们是否仍然向后兼容? “CPAN 不包含 Perl 的所有古老版本和补丁级别”,如果我创建文档说运行“cpan -i DBI”,如果最新版本的 DBI 无法在 5.8 上运行?
I'm have Perl 5.8 installed on all of our servers and wanted to use the DBI and DBD::Oracle modules to access our databases. My main concern is with the newer versions of perl the DBI and DBD modules will stop working with 5.8. Then I'd have to upgrade every server to the newest perl version.
My question is as perl itself becomes later versions and modules are developed for them will they still be backwards compatible? "CPAN does not carry all ancient releases and patchlevels of Perl", if I create documentation saying run "cpan -i DBI" if the newest version of DBI will not function with 5.8?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有任何保证。
一般来说,您希望在所有系统上使用相同版本的模块。如果您使用不同的版本,那么不同的服务器上将有不同的错误和可用功能。
我建议为您要使用的那些创建 Debs / RPMS / 等,然后运行所有服务器共享的包存储库。
There is no guarantee.
In general, you want to use the same versions of the modules on all your systems. If you use different versions then you will have different bugs and features available on different servers.
I'd suggest creating Debs / RPMS / etc for the ones you are going to use and then run a package repository that all your servers share.
不绝对,但一般来说,perl 对破坏代码相当温和,没有太多破坏性更改,而且对确实发生的更改也有很长的弃用周期。 1999 年上传到 CPAN 的大部分代码将无需修改即可在 perl 5.14 中运行。
从perl 5.12开始,perl的发布周期变得更短,弃用期也变得更短,这令人担忧,但同时功能版本控制的概念已经流行起来。这个想法是,代码可以使用
use VERSION
声明它所针对的perl版本(例如use 5.16.0
),并且任何未声明版本的代码都是假设目标约为 5.10。当针对较旧 Perl 版本的代码在较新 Perl 版本上运行时,可能会导致兼容性问题的较新功能(例如新关键字)将被禁用,并且旧的错误功能可能会以兼容性的名义重新启用。这不是绝对的保证,但我们将尽可能遵守。有关向后兼容性和弃用的更多信息,请参阅 perlpolicy。
Not absolutely, but in general perl is pretty gentle about breaking code, with not many breaking changes, and long deprecation cycles on the ones that do happen. A pretty hefty portion of the code that was uploaded to CPAN in 1999 will run without modification in perl 5.14.
Since perl 5.12, the perl release cycle has become shorter, and the deprecation periods have also become shorter, which is cause for concern, but at the same time the concept of feature versioning has gained currency. The idea is that code may declare the version of perl that it's targeting with
use VERSION
(e.g.use 5.16.0
), and any code that doesn't declare a version is assumed to be targeting approximately 5.10. When code that targets an older perl version is run on a newer perl version, newer features that might cause compatibility issues (e.g. new keywords) are disabled, and old misfeatures may be re-enabled in the name of compatibility. This isn't an absolute guarantee, but it will be adhered to as much as practical.More information about back-compatibility and deprecation is in perlpolicy.
一般来说,没有。 Perl 的最新版本中有许多很棒的新功能(
智能匹配运算符、//
运算符,例如two一个)不向后兼容。许多作者会决定利用这些功能,而不是让他们的模块与旧版本的 Perl 兼容。检查模块的 CPAN 测试人员矩阵,包括有关 最大值通过所有发行版测试的版本,以了解哪些版本的 Perl 与模块的每个版本兼容。
cpan -i Some::Module
确实会尝试安装模块Some::Module
的最新版本,但经过一些研究,它可以用于安装旧版本版本也有。您需要找到或猜测旧版本的作者,并提供 CPAN 镜像服务器上的分发路径。例如,CPAN 作者可以从 CPAN 中删除他们的旧发行版。但即便如此,如果您愿意下载、解压和构建,也可以在 BackPAN 上获得该发行版自己分配。
In general, no. There are a lot of great new features in recent releases of Perl (
smart match operator,the//
operator, fortwoone example) that are not backwards compatible. Many authors will decide to take advantage of these features rather than keep their modules compatible with older versions of Perl.Check the CPAN Tester's Matrix of a module, including the link about the max version that passes all of the distribution's tests, to get an idea of what versions of Perl are compatible with each version of a module.
cpan -i Some::Module
will indeed attempt to install the latest version of the moduleSome::Module
, but with a little research, it can be used to install older versions too. You need to find or guess the author of an older version and provide the path to the distribution on the CPAN mirror servers. For example,CPAN authors may delete their older distributions from CPAN. But even then, the distribution is available at the BackPAN if you're willing to download, unpack, and build the distribution yourself.