Upgrade Perl from 5.6 to 5.24
Asked Answered
D

4

9

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.

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.

Is it advisable to move from this much lower version to advanced level?

Daunt answered 12/8, 2016 at 8:56 Comment(3)
List of Perl 5 versions (with dates. 1996-02-03 to 2020-11-20. 446 versions).Barfuss
It is a bit terse, though. For instance, it is not easy to deduce that the Perl debugger documentation was broken with the renaming of command letters in version 5.7.3 (2002-03-05). The book Programming Perl (the "Camel Book"), 4th edition, released 10 years later (2012-02-13) did not have the changes (and it is still not in the errata - that is more than 18 years that a sort of canonical documentation has been out of date). There are also copy-paste errors on page 613, with overwritten/missing information.Barfuss
@brian d foy: For instance, page 605 (third release, 2013-12-13) claims that the 'w' command will display a "window" of source code. That is not the case for later versions of Perl. 'w' is now for "watch" (conditional breakpoints). The new command for listing a few lines around the given source line is 'v'.Barfuss
V
15

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. 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.

There are number of notable differences:

  • 5.8 changed binary format, so you have to recompile .XS modules.
  • 5.8 moved to PerlIO for core I/O operations.
  • 5.8 changed how wide-character strings work. This changed the role of use utf8.
  • 5.10 made unpack() and mkdir() default to using $_
  • 5.10 retired $* and $#
  • 5.10 made it that $AUTOLOAD, printf and sprintf are now taintable
  • 5.12 reordered @INC to allow core modules to be upgraded
  • 5.12 blesses file handles into IO::File
  • 5.12 suidperl was dropped
  • 5.12 deprecated UNIVERSAL->import()
  • 5.14 was another binary incompability change
  • 5.14 change the referencing of glob handles.
  • 5.14 local($_) strips all magic from $_
  • 5.14 := became a syntax error
  • 5.18 hash ordering is even less predictable than before
  • 5.18 \s now matches \cK (the vertical tab)
  • 5.18 readline() with $/ = \N now reads N characters, not N bytes
  • 5.20 do SUBROUTINE(LIST) became a syntax error
  • 5.20 for certain data structures, Data::Dumper output has changed
  • 5.24 Lexical $_ was removed
  • 5.24 chdir('') no longer changes directory to 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. 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. 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.

Vitriol answered 12/8, 2016 at 9:43 Comment(0)
A
10

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. Run your test suite until everything still compiles and works perfectly under Perl v5.5.

Install Perl v5.24 on a test system and adjust your sources until they pass every test.

The Perl 5 crew have been excellent about keeping backward compatibility, but there will almost certainly be some casualties.

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.

Antiphony answered 12/8, 2016 at 10:5 Comment(0)
A
3

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.

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.

Antiphony answered 12/8, 2016 at 11:3 Comment(0)
S
2

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". Those are the release notes for each new version of Perl. They contain details of everything has changed since the previous version of Perl.

5.6 to 5.24 is a huge leap (about 30 versions!) I can see a lot of reading in your future!

Perhaps in the future you'll realise the importance of keeping your software versions a little more up to date :-)

Sextuplicate answered 12/8, 2016 at 9:24 Comment(3)
I make that nine major public versions, which is plenty. I think it's disingenuous to count minor and development versions.Antiphony
I didn't count development versions. Or minor versions that were released after the next major version. But I think it's fair to count minor versions (as that's when you should at least be thinking about upgrading). On a more careful recount, I make it 34 versions. But, yes, "only" nine major versions.Sextuplicate
Nine is plenty :) But I wouldn't want my team upgrading on every increment unless it was for a bug fix. Mostly stuff keeps working, and upgrades generally offer just new shinies (although I try to keep a v5.10 base).Antiphony

© 2022 - 2024 — McMap. All rights reserved.