简体   繁体   English

将 Perl 从 5.6 升级到 5.24

[英]Upgrade Perl from 5.6 to 5.24

We are currently using 5.6 version of Perl in our organisation, along with MySQL and Apache, but now the client wants to upgrade Perl to v5.24.我们目前在我们的组织中使用 5.6 版本的 Perl,以及 MySQL 和 Apache,但现在客户想要将 Perl 升级到 v5.24。

What are all the major changes and key points that must be kept in mind before starting an upgrade?在开始升级之前必须牢记的所有主要变化和关键点是什么?

I surfed a lot, but I didn't find anything interesting for moving from 5.6 to 5.24.我冲浪了很多,但我没有发现从 5.6 移动到 5.24 的任何有趣之处。

Is it advisable to move from this much lower version to advanced level?是否建议从这个低得多的版本转到高级版本?

If you go to CPAN for the chosen version of you are moving to (in your case 5.24.0 Perl 5.24.0 ), and look down in the Documentation section there are bunch of perlXXXdelta links.如果您转到 CPAN 以获取要迁移到的所选版本(在您的情况下为 5.24.0 Perl 5.24.0 ),并在文档部分向下查看,那里有一堆perlXXXdelta链接。 These files describe the changes between revisions and more importantly they detail the incompatible changes.这些文件描述了修订之间的更改,更重要的是它们详细说明了不兼容的更改。 You can also find these online .您也可以在网上找到这些。

Version 5.24.0 details its changes in pod/perldelta.pod .版本 5.24.0 详细说明了它在pod/perldelta.pod变化。

There are number of notable differences:有许多显着差异:

  • 5.8 changed binary format, so you have to recompile .XS modules. 5.8 更改了二进制格式,因此您必须重新编译 .XS 模块。
  • 5.8 moved to PerlIO for core I/O operations. 5.8 移至 PerlIO 进行核心 I/O 操作。
  • 5.8 changed how wide-character strings work. 5.8 改变了宽字符串的工作方式。 This changed the role of use utf8 .这改变了use utf8的作用。
  • 5.10 made unpack() and mkdir() default to using $_ 5.10 使unpack()mkdir()默认使用$_
  • 5.10 retired $* and $# 5.10 退休$*$#
  • 5.10 made it that $AUTOLOAD , printf and sprintf are now taintable 5.10 使得$AUTOLOADprintfsprintf现在是可污染的
  • 5.12 reordered @INC to allow core modules to be upgraded 5.12 重新排序@INC以允许升级核心模块
  • 5.12 blesses file handles into IO::File 5.12 祝福文件句柄变成IO::File
  • 5.12 suidperl was dropped 5.12 suidperl 被删除
  • 5.12 deprecated UNIVERSAL->import() 5.12 弃用UNIVERSAL->import()
  • 5.14 was another binary incompability change 5.14 是另一个二进制不兼容变化
  • 5.14 change the referencing of glob handles. 5.14 更改 glob 句柄的引用。
  • 5.14 local($_) strips all magic from $_ 5.14 local($_)$_去除所有魔法
  • 5.14 := became a syntax error 5.14 :=成为语法错误
  • 5.18 hash ordering is even less predictable than before 5.18 哈希排序比以前更难预测
  • 5.18 \\s now matches \\cK (the vertical tab) 5.18 \\s现在匹配\\cK (垂直制表符)
  • 5.18 readline() with $/ = \\N now reads N characters, not N bytes 5.18 带有$/ = \\N readline()现在读取 N 个字符,而不是 N 个字节
  • 5.20 do SUBROUTINE(LIST) became a syntax error 5.20 do SUBROUTINE(LIST)变成了语法错误
  • 5.20 for certain data structures, Data::Dumper output has changed 5.20 对于某些数据结构, Data::Dumper输出已更改
  • 5.24 Lexical $_ was removed 5.24 词法$_被删除
  • 5.24 chdir('') no longer changes directory to home 5.24 chdir('')不再将目录更改为 home

I would suggest you go over these files in detail (it will keep you busy given your huge version bump!).我建议您详细查看这些文件(鉴于您的巨大版本颠簸,它会让您忙碌!)。 This is especially the case if you have a good knowledge of your code base and the Perl features it utilizes.如果您对代码库及其使用的 Perl 功能有很好的了解,则尤其如此。 This should at least give you a sense of the potential pitfalls you may face in migrating to later versions.这至少应该让您了解在迁移到更高版本时可能面临的潜在陷阱。

I would also add that Borodin's answer is worth a read, as it details a very good approach to dealing with the upgrade.我还要补充一点,Borodin 的回答值得一读,因为它详细介绍了处理升级的非常好的方法。 I agree wholeheartedly with his recommendations, especially unit testing - it is a sure way to increase confidence in the success of the migration.我完全同意他的建议,尤其是单元测试——这是增加对迁移成功的信心的可靠方法。 If you have no unit tests, then this would be an excellent time to introduce them, as well as being able to justify the time spent creating them for your organisation.如果您没有单元测试,那么这将是介绍它们的绝佳时机,并且能够证明为您的组织创建它们所花费的时间是合理的。

I think educating yourselves on the differences will be useful, but there is no way that it is feasible to work through all the delta files and check all of your sources for discrepancies.我认为让自己了解差异会很有用,但是没有办法处理所有增量文件并检查所有来源是否存在差异。

Hopefully you have unit tests for your software suite.希望您对您的软件套件进行了单元测试。 If not, then understand now why they are useful and write comprehensive tests for everything that you have.如果没有,那么现在就了解它们为什么有用并为您拥有的所有内容编写全面的测试。

Make a fork in your version control system, and add use strict and use warnings 'all' to the top of every source file if they aren't already there.在您的版本控制系统中创建一个分支,并在每个源文件的顶部添加use strictuse warnings 'all' (如果它们尚未存在)。 Run your test suite until everything still compiles and works perfectly under Perl v5.5.运行您的测试套件,直到一切仍然可以编译并在 Perl v5.5 下完美运行。

Install Perl v5.24 on a test system and adjust your sources until they pass every test.在测试系统上安装 Perl v5.24 并调整您的源代码,直到它们通过每个测试。

The Perl 5 crew have been excellent about keeping backward compatibility, but there will almost certainly be some casualties. Perl 5 团队在保持向后兼容性方面表现出色,但几乎肯定会出现一些伤亡。

When you're confident, make the new version live.当你有信心时,让新版本上线。 There will be more failures, and for every one you must write a new test into your test suites.将会有更多的失败,对于每一个你都必须在你的测试套件中编写一个新的测试。

Is it advisable to move from this much lower version to advanced level?是否建议从这个低得多的版本转到高级版本?

Absolutely yes.绝对是的。 The Perl 5 team have worked very hard to remove bugs and add features to every release of Perl while keeping 100% backward-compatibility through every release of Perl 5. Perl 5 团队非常努力地消除错误并为 Perl 的每个版本添加功能,同时在 Perl 5 的每个版本中保持 100% 向后兼容性。

If you encounter any problems then it will be because of dubious code or because a warning is now issued because of newly-deprecated syntax.如果您遇到任何问题,那么这将是由于可疑代码或由于新弃用的语法而现在发出警告。

If you look at the release page on for Perl 5.24 on CPAN, you'll see that the documentation contains a number of files called "perl5xxxdelta".如果您查看 CPAN上 Perl 5.24发布页面,您会看到该文档包含许多名为“perl5xxxdelta”的文件。 Those are the release notes for each new version of Perl.这些是每个新版本 Perl 的发行说明。 They contain details of everything has changed since the previous version of Perl.它们包含自上一版 Perl 以来所有更改的详细信息。

5.6 to 5.24 is a huge leap (about 30 versions!) I can see a lot of reading in your future! 5.6 到 5.24 是一个巨大的飞跃(大约 30 个版本!)我可以看到你未来的大量阅读!

Perhaps in the future you'll realise the importance of keeping your software versions a little more up to date :-)也许在未来你会意识到让你的软件版本保持最新的重要性:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM