1. Perl
  2. Version information
  3. here

The latest version of Perl, Perl 5.26 released. Indentable Here Documents, Unicode 9.0, Long Key Hash Performance Improvements

Perl 5.26 was released on May 30, 2017! Perl was introduced in 1987, so it's finally 30 years!

Addition of functions

Some feature additions in Perl 5.26. I will pick up something that seems convenient.

Indentable here document

Indentable Here Document syntax has been added. This seems convenient.

my $message = << ~ EOS;
  Hello
  World
  EOS

The position of the last character (EOS in this case) is the position on the left, and the output result is as follows.

Hello
World

It would be even better if you could color the source code well in the editor.

Unicode 9.0 support

Unicode 9.0 is supported. It can handle emoticons and other characters added in Unicode 9.0.

Formal functions of lexical subroutine

The functionality of the lexical subroutine is now official.

{
  my sub foo {
    ...
  }
  
  # Can be called only from the current scope.
  title ();
}

Regular expression named captures are easier to understand

The use of named captures for regular expression has become easier to understand. You can retrieve the named capture from the following a hash variable.

%{^CAPTURE}
my $foo = "I am Tom" ;;
if ($a =~ m/(? <name>. +)$/) {
  my $name = ${^CAPTURE}{name};
}

It was a little confusing to refer to with "$+ {name}", so I think this is a good addition.

Performance improvements

Pick up on performance improvements in Perl 5.26.

Hash performance improvement in 64 - bit environment

Now hybrid hash for better balance.

Use the "At A Time Hard" algorithm for short keys of 16 bytes or less and the "Siphash 1-3" algorithm for long keys.

Very long keys will significantly improve performance, short keys will have a small improvement.

Faster line reading from file

Improved performance for readline, which reads files from lines, and the "<>" operator. The implementation of the line break character search method is now faster.

Faster reference assignment

Assigning a reference to another variable is faster.

my $obj1 = SomeModule->new;
my $obj2 = $obj1;

Improved performance of split function

split function is slightly faster.

my @elements = split ...;

Improved list assignment performance

List Assignment performance is about 3x faster.

my @elements = (1,2,3);

Backwards incompatible changes

This is a backwards incompatible change.

The "." That was added by default at the end of @INC has been removed

In Perl 5.26, this is the most impactful and incompatible change. Changes have been made to remove the current directory in the module's loading path, which poses a security risk.

Please see the following article for details.

Unescaped "{" in a regular expression is not allowed

It has been deprecated since 5.16, but is no longer allowed in Perl 5.26.

# Whenever you use "{" in a regular expression, escape
/\{/;

${^ENCODING} feature removed

The encoding pragma was deprecated in Perl 5.18, but with this release the encoding pragma no longer works out of the box. This is because the ${^ENCODING} variable, which was internally connected to the encoding pragma, has been removed.

Write the source code in UTF-8 and use the utf8 pragma.

If you really want to continue using the encoding pragma, you can deal with it by adding the "Filter" option as shown below.

use encoding "euc-jp", Filter => 1;

Impressions

Changes that make Perl easier to understand and performance improvements are welcome. It's also great to be ready for the new Unicode soon.

The removal of the "." From @INC has a significant impact on the source code, but I think it's a better decision than leaving the security issues alone.

Upgrading to Perl 5.26 requires a great deal of caution. It is best to deal with it in advance. It is a good idea to set the path to read modules and files in the FindBin module with an absolute path.

It was stable up to Perl 5.20, and in Perl 5.22 and Perl 5.24 there was a problem with Coro using the internal API not working. Currently the latest version of Coro seems to work with Perl 5.22, but not with Perl 5.24 or later. In Perl 5.26, the "." Is removed from @INC.

The precautions for the upgrade are to make sure you are not using Coro and to take action to prevent the "." From being included in @INC.

If you're using an older Perl, upgrade to Perl 5.20 first, then upgrade to the latest version, and you'll be less likely to have problems.

Related Informatrion