PERL5400DELTA(1)

πŸ’– PERL5400DELTA β€” what's new for perl v5.40.0 πŸ’–

okay bestie, gather round, because this is perl5400delta, part of the Perl Programmers Reference Guide, and it's literally the glow-up diary of Perl. ✨


🌸 NAME 🌸

perl5400delta β€” what is new for perl v5.40.0. yes that's the whole name, she's simple like that πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This doc spills all the tea on the differences between the 5.38.0 release and the 5.40.0 release. that's it. that's the description. periodt.


πŸ‘‘ Core Enhancements πŸ‘‘

✨ New __CLASS__ Keyword ✨

so when you're using the new class feature, code inside a method, an ADJUST block, or a field initializer expression can now use the brand-new __CLASS__ keyword. πŸŽ€

it hands you a class name, kinda like __PACKAGE__, BUT β€” and this is the iconic part β€” while __PACKAGE__ gives you the compile-time package the code appears in, __CLASS__ is aware of the actual run-time class that the object instance is a member of. main character energy, fr fr. this makes it super useful for method dispatch on that class, especially during constructors, where you're not allowed to touch $self. 😀

for more info, go peek at "__CLASS__" in perlfunc.

🌈 :reader attribute for field variables 🌈

when you're in your class feature era, field variables can now take a :reader attribute. what does it do? it politely requests that an accessor method be automatically created that just returns the value of the field variable from the given instance. slay.

field $name :reader;

is equivalent to

field $name;
method name () { return $name; }

you can also give it an alternative name, because customization is self-care:

field $name :reader(get_name);

for more detail, see ":reader" in perlclass. πŸ’œ

πŸ’… Permit a space in -M command-line option πŸ’…

when perl is processing command-line options, it now allows a space between the -M switch and the name of the module after it. no cap.

$ perl -M Data::Dumper=Dumper -E 'say Dumper [1,2,3]'

this matches the existing behaviour of the -I option. consistency queen. πŸ‘‘

🚨 Restrictions to use VERSION declarations 🚨

back in Perl 5.36, a deprecation warning got added for when you downgrade a use VERSION declaration from one above version 5.11 down to below. welp, that's now a fatal error. 😭

also: it's now a fatal error to issue a subsequent use VERSION declaration when another one is in scope, when either version is 5.39 or above. this is to avoid complications surrounding imported lexical functions from builtin. and a deprecation warning has also been added for any other subsequent use VERSION declaration below version 5.39, warning you that it will no longer be permitted in Perl version 5.44. consider this your warning bestie 🫢

🌟 New builtin::inf and builtin::nan functions (experimental) 🌟

two new functions, inf and nan, have joined the builtin namespace. they act like constants that yield the floating-point infinity and Not-a-Number value respectively. infinity and void, iconic duo. ✨

πŸ”₯ New ^^ logical xor operator πŸ”₯

Perl has always had three low-precedence logical operators β€” and, or and xor β€” plus three high-precedence bitwise versions &, ^ and |. but until this release, even though the medium-precedence logical operators && and || were also hanging around, there was NO exclusive-or equivalent. the set was incomplete. the tragedy. πŸ’€

this release of Perl adds the final ^^ operator, completing the set. she's the missing piece. the final girlboss.

$x ^^ $y and say "One of x or y is true, but not both";

πŸŽ€ try/catch feature is no longer experimental πŸŽ€

before this release, the try/catch feature for handling errors was considered experimental. it was introduced way back in Perl version 5.34.0, and now it's officially a stable language feature and using it no longer prints a warning. glow-up complete. πŸ’– it still must be enabled with the 'try' feature though, don't forget.

see "Try Catch Exception Handling" in perlsyn.

πŸ¦‹ for iterating over multiple values at a time is no longer experimental πŸ¦‹

previously, iterating over multiple values at a time with for was experimental. introduced in Perl version 5.36.0, it's now a stable language feature and using it no longer prints a warning. she graduated. πŸŽ“

see "Compound Statements" in perlsyn.

🌸 builtin module is no longer experimental 🌸

before this release, the builtin module and all of its functions were considered experimental. introduced in Perl version 5.36.0, this module is now considered stable and its use no longer prints a warning. HOWEVER β€” plot twist β€” several of its functions are still considered experimental. πŸ™ˆ so like, the module ate, but some of the functions are still in their testing era.

⭐ The :5.40 feature bundle adds try ⭐

the latest version feature bundle now contains the recently-stablized feature try. and since this feature bundle is used by the -E commandline switch, these are immediately available in -E scripts. instant access, no assembly required. πŸ”₯

πŸ’œ use v5.40; imports builtin functions πŸ’œ

in addition to importing a feature bundle, use v5.40; (or later versions) imports the corresponding builtin version bundle. two for one, we love a bundle deal. 🎁


πŸ”’ Security πŸ”’

πŸ’€ CVE-2023-47038 - Write past buffer end via illegal user-defined Unicode property πŸ’€

this vulnerability was reported directly to the Perl security team by Nathan Mills the.true.nathan.mills@gmail.com. thank you Nathan, king behaviour. 🫑

a crafted regular expression, when compiled by perl 5.30.0 through 5.38.0, can cause a one-byte attacker controlled buffer overflow in a heap allocated buffer. that's a whole yikes, no cap.

πŸ’€ CVE-2023-47039 - Perl for Windows binary hijacking vulnerability πŸ’€

this vulnerability was reported to the Intel Product Security Incident Response Team (PSIRT) by GitHub user ycdxsb <https://github.com/ycdxsb/WindowsPrivilegeEscalation>. PSIRT then reported it to the Perl security team. chain of custody, we love to see it.

Perl for Windows relies on the system path environment variable to find the shell (cmd.exe). when running an executable which uses the Windows Perl interpreter, Perl attempts to find and execute cmd.exe within the operating system. HOWEVER β€” due to path search order issues β€” Perl initially looks for cmd.exe in the current working directory. πŸ™ƒ

an attacker with limited privileges can exploit this behavior by placing cmd.exe in locations with weak permissions, such as C:\ProgramData. by doing so, when an administrator attempts to use this executable from these compromised locations, arbitrary code can be executed. genuinely terrifying, stay safe out there bestie 🚨


😭 Incompatible Changes 😭

πŸŒ€ reset EXPR now calls set-magic on scalars πŸŒ€

previously, reset EXPR did not call set magic when clearing scalar variables. this meant changes didn't propagate to the underlying internal state where needed β€” like for $^W β€” and didn't result in an exception where the underlying magic would normally throw one, like for $1.

so basically: code that had no effect before may now actually have an effect, including possibly throwing an exception. surprises incoming. πŸ™ˆ

reset EXPR already called set magic when modifying arrays and hashes, for the record.

this has no effect on plain reset used to reset one-match searches as with m?pattern?. that one's fine. breathe.

[GH #20763 <https://github.com/Perl/perl5/issues/20763>]

πŸŒ€ Calling the import method of an unknown package produces a warning πŸŒ€

historically, it's been possible to call the import or unimport method of any class β€” including ones which have not been defined β€” with an argument, and not experience an error. for instance, this code will not throw an error in Perl 5.38:

Class::That::Does::Not::Exist->import("foo");

but as of Perl 5.39.1, this is deprecated and will issue a warning. πŸ“’

note that calling these methods with no arguments continues to silently succeed and do nothing. for instance,

Class::That::Does::Not::Exist->import();

will continue to not throw an error. why? because every class implicitly inherits from the class UNIVERSAL, which now defines an import method. in older perls there was no such method defined, and instead the method calls for import and unimport were special cased to not throw errors if there was no such method defined. lore. πŸ“š

this change was added because it makes it easier to detect case typos in use statements when running on case-insensitive file systems. for instance, on Windows or other platforms with case-insensitive file systems, on older perls the following code

use STRICT 'refs';

would silently do nothing, because the module is actually called strict.pm, not STRICT.pm β€” so it would be loaded but its import method would never be called. sneaky. πŸ™ƒ it will also detect cases where a user passes an argument when using a package that does not provide its own import β€” for instance, most "pure" class definitions do not define an import method.

πŸŒ€ return no longer allows an indirect object πŸŒ€

the return operator syntax now rejects indirect objects. in most cases this would compile and even run, but it wasn't documented and could produce confusing results. example:

# note that sum hasn't been defined
sub sum_positive {
    return sum grep $_ > 0, @_;
    # unexpectedly parsed as:
    #   return *sum, grep $_ > 0, @_;
    # ... with the bareword acting like an extra (typeglob) argument
}
say for sum_positive(-1, 2, 3)

produced:

*main::sum
2
3

yeah. that's the chaos we're no longer tolerating. πŸ’…

[GH #21716 <https://github.com/Perl/perl5/issues/21716>]

πŸŒ€ Class barewords no longer resolved as file handles in method calls under no feature "bareword_filehandles" πŸŒ€

under no feature "bareword_filehandles", bareword file handles continued to be resolved in method calls:

open FH, "<", $somefile or die;
no feature 'bareword_filehandles';
FH->binmode;

this has been fixed, so the:

FH->binmode;

will attempt to resolve FH as a class, typically resulting in a runtime error. 😬

the standard file handles such as STDOUT continue to be resolved as a handle:

no feature 'bareword_filehandles';
STDOUT->flush; # continues to work

note that once perl resolves a bareword name as a class, it will continue to do so:

package SomeClass {
    sub somemethod{}
}
open SomeClass, "<", "somefile" or die;
# SomeClass resolved as a handle
SomeClass->binmode;
{
    no feature "bareword_filehandles";
    SomeClass->somemethod;
}
# SomeClass resolved as a class
SomeClass->binmode;

once she picks a lane, she stays in it. πŸš—

[GH #19426 <https://github.com/Perl/perl5/issues/19426>]


🌧️ Deprecations 🌧️


πŸš€ Performance Enhancements πŸš€

🌸 MODULES AND PRAGMATA 🌸

bestie this is the part where we go through every single module that got added or glow-up'd in this release. it's giving inventory, it's giving receipts, and yes we are listing all of them πŸ’…


✨ New Modules and Pragmata ✨

  • Term::Table 0.018 β€” brand new in the core, bestie πŸŽ€
    • it's a dependency of Test2::Suite, that's the whole reason it's here.
  • Test2::Suite 0.000162 β€” also brand new in the core ✨
    • this distribution is a whole comprehensive set of test tools for writing unit tests.
    • it's the successor to Test::More and similar modules.
    • the reason it's in core now: CPAN module tests can be written using this suite of tools without extra dependencies. no cap. πŸ™Œ

πŸ’… Updated Modules and Pragmata πŸ’…

okay so here's the big list. everything below got a version bump, and a few of them got actual lore too 🧚

  • Archive::Tar β€” upgraded from version 2.40 to 3.02_001.
  • attributes β€” upgraded from version 0.35 to 0.36.
  • autodie β€” upgraded from version 2.36 to 2.37.
  • B β€” upgraded from version 1.88 to 1.89.
  • B::Deparse β€” upgraded from version 1.74 to 1.76.
  • Benchmark β€” upgraded from version 1.24 to 1.25.
  • bignum β€” upgraded from version 0.66 to 0.67.
  • builtin β€” upgraded from version 0.008 to 0.014. this one ATE πŸ”₯
    • builtin now accepts a version bundle as an input argument, which requests that it import all of the functions that are considered a stable part of the module at the given Perl version. like, for example:
use builtin ':5.40';
  • bytes β€” upgraded from version 1.08 to 1.09.
  • Compress::Raw::Bzip2 β€” upgraded from version 2.204_001 to 2.212.
  • Compress::Raw::Zlib β€” upgraded from version 2.204_001 to 2.212.
  • CPAN::Meta::Requirements β€” upgraded from version 2.140 to 2.143.
  • Data::Dumper β€” upgraded from version 2.188 to 2.189.
  • DB_File β€” upgraded from version 1.858 to 1.859.
  • Devel::Peek β€” upgraded from version 1.33 to 1.34.
  • Devel::PPPort β€” upgraded from version 3.71 to 3.72.
  • diagnostics β€” upgraded from version 1.39 to 1.40.
  • DynaLoader β€” upgraded from version 1.54 to 1.56.
  • Encode β€” upgraded from version 3.19 to 3.21.
  • Errno β€” upgraded from version 1.37 to 1.38.
    • the osvers and archname baked into the module (the ones that make sure Errno gets loaded by the perl that built it) are now more comprehensively escaped. 🫢 GH #21135 β€” https://github.com/Perl/perl5/issues/21135
  • experimental β€” upgraded from version 0.031 to 0.032.
  • Exporter β€” upgraded from version 5.77 to 5.78.
  • ExtUtils::CBuilder β€” upgraded from version 0.280238 to 0.280240.
  • ExtUtils::Manifest β€” upgraded from version 1.73 to 1.75.
  • ExtUtils::Miniperl β€” upgraded from version 1.13 to 1.14.
  • Fcntl β€” upgraded from version 1.15 to 1.18.
    • the old module documentation stub has been greatly expanded and revised. πŸ“–
    • adds support for the O_TMPFILE flag on Linux.
  • feature β€” upgraded from version 1.82 to 1.89.
    • it now documents the :all feature bundle, and it also suggests a reason why you may not wish to use it. πŸ‘€
  • fields β€” upgraded from version 2.24 to 2.25.
  • File::Compare β€” upgraded from version 1.1007 to 1.1008.
  • File::Find β€” upgraded from version 1.43 to 1.44.
  • File::Glob β€” upgraded from version 1.40 to 1.42.
  • File::Spec β€” upgraded from version 3.89 to 3.90.
  • File::stat β€” upgraded from version 1.13 to 1.14.
  • FindBin β€” upgraded from version 1.53 to 1.54.
  • Getopt::Long β€” upgraded from version 2.54 to 2.57.
  • Getopt::Std β€” upgraded from version 1.13 to 1.14.
    • documentation and test improvements only; no change in functionality. it's giving glow-up with zero plot twists πŸ’–
  • Hash::Util β€” upgraded from version 0.30 to 0.32.
  • Hash::Util::FieldHash β€” upgraded from version 1.26 to 1.27.
  • HTTP::Tiny β€” upgraded from version 0.086 to 0.088.
  • I18N::Langinfo β€” upgraded from version 0.22 to 0.24.
    • it now handles the additional locale categories that Linux defines beyond those in the POSIX Standard.
    • this fixes what is returned for the ALT_DIGITS item, which has never before worked properly in Perl. literal historic moment 😭
  • IO β€” upgraded from version 1.52 to 1.55.
  • IO-Compress β€” upgraded from version 2.204 to 2.212.
  • IO::Socket::IP β€” upgraded from version 0.41_01 to 0.42.
  • IO::Zlib β€” upgraded from version 1.14 to 1.15.
  • locale β€” upgraded from version 1.10 to 1.12.
  • Math::BigInt β€” upgraded from version 1.999837 to 2.003002.
  • Math::BigInt::FastCalc β€” upgraded from version 0.5013 to 0.5018.
  • Module::CoreList β€” upgraded from version 5.20230520 to 5.20240609.
  • Module::Metadata β€” upgraded from version 1.000037 to 1.000038.
  • mro β€” upgraded from version 1.28 to 1.29.
  • NDBM_File β€” upgraded from version 1.16 to 1.17.
  • Opcode β€” upgraded from version 1.64 to 1.65.
  • perl5db.pl β€” upgraded from version 1.77 to 1.78.
  • perlfaq β€” upgraded from version 5.20210520 to 5.20240218.
  • PerlIO::encoding β€” upgraded from version 0.30 to 0.31.
  • PerlIO::scalar β€” upgraded from version 0.31 to 0.32.
  • PerlIO::via β€” upgraded from version 0.18 to 0.19.
  • Pod::Checker β€” upgraded from version 1.75 to 1.77.
  • Pod::Html β€” upgraded from version 1.34 to 1.35.
  • Pod::Simple β€” upgraded from version 3.43 to 3.45.
  • podlators β€” upgraded from version 5.01 to 5.01_02.
  • POSIX β€” upgraded from version 2.13 to 2.20. this one has a whole saga, bestie πŸ“š
    • the mktime function now works correctly on 32-bit platforms even if the platform's time_t type is larger than 32 bits. GH #21551 β€” https://github.com/Perl/perl5/issues/21551
    • the T_SIGNO and T_FD typemap entries have been fixed so they work with any variable name, rather than just the hardcoded sig and fd.
    • the mappings for Mode_t, pid_t, Uid_t, Gid_t and Time_t have been updated to be integer types; previously they were NV floating-point.
    • adjusted the signbit() on NaN test to handle the unusual bit pattern returned for NaN by Oracle Developer Studio's compiler. GH #21533 β€” https://github.com/Perl/perl5/issues/21533
  • re β€” upgraded from version 0.44 to 0.47.
  • Safe β€” upgraded from version 2.44 to 2.46.
  • SelfLoader β€” upgraded from version 1.26 to 1.27.
  • Socket β€” upgraded from version 2.036 to 2.038.
  • strict β€” upgraded from version 1.12 to 1.13.
  • Test::Harness β€” upgraded from version 3.44 to 3.48.
  • Test::Simple β€” upgraded from version 1.302194 to 1.302199.
  • Text::Tabs β€” upgraded from version 2021.0814 to 2024.001.
  • Text::Wrap β€” upgraded from version 2021.0814 to 2024.001.
  • threads β€” upgraded from version 2.36 to 2.40.
    • an internal error has been made slightly more verbose: Out of memory in perl:threads:ithread_create. πŸ’€ at least now you know what ran out of memory.
  • threads::shared β€” upgraded from version 1.68 to 1.69.
  • Tie::File β€” upgraded from version 1.07 to 1.09.
    • old compatibility code for perl 5.005 that was no longer functional has been removed. bye boo πŸ‘‹
  • Time::gmtime β€” upgraded from version 1.04 to 1.05.
  • Time::HiRes β€” upgraded from version 1.9775 to 1.9777.
  • Time::Local β€” upgraded from version 1.30 to 1.35.
  • Time::localtime β€” upgraded from version 1.03 to 1.04.
  • Time::tm β€” upgraded from version 1.00 to 1.01.
  • UNIVERSAL β€” upgraded from version 1.15 to 1.17.
  • User::grent β€” upgraded from version 1.04 to 1.05.
  • User::pwent β€” upgraded from version 1.02 to 1.03.
  • version β€” upgraded from version 0.9929 to 0.9930.
  • warnings β€” upgraded from version 1.65 to 1.69.
  • XS::APItest β€” upgraded from version 1.32 to 1.36.
  • XS::Typemap β€” upgraded from version 0.19 to 0.20.

πŸ“š Documentation

✨ Changes to Existing Documentation ✨

okay so bestie, the whole team tried to make the docs match everything listed in this doc, and if you spot something they missed you can open an issue at https://github.com/Perl/perl5/issues. πŸ’–

And also, these specific glow-ups happened:

  • perlapi
    • Fixed the docs for Perl_form, form_nocontext, and vform, which used to claim that any later call to one of them will destroy the previous returns from any. That has not been true since 5.6.0 β€” except it does still remain true if these are called during global destruction. With that caveat, the return of each of these is a fresh string in a temporary that will automatically be freed by a call to "FREETMPS" in perlapi, or at places such as statement boundaries.
    • Several internal functions now have docs β€” the various newSUB functions, newANONLIST(), newANONHASH(), newSVREF() and similar. πŸŽ€
  • perlclass
    • Added a list of known bugs in the experimental class feature. (yes, we're being honest about them, iconic behaviour)
  • perlfunc
    • The docs for local, my, our, and state got updated to include examples and descriptions of their effects within a statement.
  • perlguts
    • A whole new section describing the experimental reference-counted argument stack build option (PERL_RC_STACK).
  • perlclib
    • Extensive guidance for interfacing with the standard C library, including many more functions to avoid, plus how to cope with locales and threads. πŸ¦‹
  • perlhacktips
    • Documented that we can't use compound literals or array designators due to C++ compatibility. [GH #21073 <https://github.com/Perl/perl5/issues/21073>]
    • Documented new functions sv_mark_arenas() and sv_sweep_arenas() (which only exist on DEBUGGING builds).
    • Added brief docs for some tools useful when developing perl itself on Windows or Cygwin.
  • perllol
    • Removed indirect object syntax in the Dumpvalue example.
  • perlre
    • Removed the statement suggesting /p is a no-op.
  • perlref
    • Documented ref assignment in list context (as part of the refaliasing feature).
  • perlop
    • The section on the empty pattern // got amended to mention that the current dynamic scope is used to find the last successful match.
  • perlport
    • The -S file test has been meaningful on Win32 since 5.37.6.
    • The -l file test is now meaningful on Win32.
    • Some strange behaviour with . at the end of names under Windows has been documented.
  • perlvar
    • Added documentation for an alternative to ${^CAPTURE}.

🚨 Diagnostics 🚨

These are the additions and changes to diagnostic output, including warnings and fatal error messages. For the complete list of diagnostic messages, see perldiag.

πŸ’₯ New Diagnostics πŸ’₯

New Errors

  • Cannot use __CLASS__ outside of a method or field initializer expression (F) A __CLASS__ expression yields the class name of the object instance executing the current method, and therefore it can only be placed inside an actual method (or method-like expression, such as a field initializer expression).
  • get_layers: unknown argument '%s' (F) You called PerlIO::get_layers() with an unknown argument. Legal arguments are provided in key/value pairs, with the keys being one of input, output or detail, followed by a boolean.
  • UNIVERSAL does not export anything (F) You asked UNIVERSAL to export something, but UNIVERSAL is the base class for all classes and contains no exportable symbols. (like babe, there's literally nothing to hand out πŸ’€)
  • Builtin version bundle "%s" is not supported by Perl (F) You attempted to use builtin :ver for a version number that is either older than 5.39 (when the ability was added), or newer than the current perl version.
  • Invalid version bundle "%s" (F) A version number that is used to specify an import bundle during a use builtin ... statement must be formatted as :MAJOR.MINOR with an optional third component, which is ignored. Each component must be a number of 1 to 3 digits. No other characters are permitted. The value that was specified does not conform to these rules.
  • Missing comma after first argument to return (F) While certain operators allow you to specify a filehandle or an "indirect object" before the argument list, return isn't one of them.
  • Out of memory during vec in lvalue context (F) An attempt was made to extend a string beyond the largest possible memory allocation by assigning to vec() called with a large second argument.

(This case used to throw a generic Out of memory! error.)

  • Cannot create an object of incomplete class "%s" (F) An attempt was made to create an object of a class where the start of the class definition has been seen, but the class has not been completed.

This can happen for a failed eval, or if you attempt to create an object at compile time before the class is complete:

eval "class Foo {"; Foo->new; # error
class Bar { BEGIN { Bar->new } }; # error

Previously perl would assert or crash. [GH #22159 <https://github.com/Perl/perl5/issues/22159>]

New Warnings

  • Forked open '%s' not meaningful in <> (S inplace) You had |- or -| in @ARGV and tried to use <> to read from it.

Previously this would fork and produce a confusing error message. [GH #21176 <https://github.com/Perl/perl5/issues/21176>]

  • Attempt to call undefined %s method with arguments ("%s"%s) via package "%s" (Perhaps you forgot to load the package?) (D deprecated::missing_import_called_with_args) You called the import() or unimport() method of a class that has no import method defined in its inheritance graph, and passed an argument to the method. This is very often the sign of a misspelled package name in a use or require statement that has silently succeeded due to a case insensitive file system.

Another common reason this may happen is when mistakenly attempting to import or unimport a symbol from a class definition or package which does not use Exporter or otherwise define its own import or unimport method.

πŸ”§ Changes to Existing Diagnostics πŸ”§

  • Name "%s::%s" used only once: possible typo

This warning now honors being marked as fatal. [GH #13814 <https://github.com/Perl/perl5/issues/13814>]

  • Out of memory in perl:%s

There used to be several places in the perl core that would print a generic Out of memory! message and abort when memory allocation failed, giving no indication which program it was that ran out of memory. These have been modified to include the word perl and the general area of the allocation failure, e.g. Out of memory in perl:util:safesysrealloc. [GH #21672 <https://github.com/Perl/perl5/issues/21672>]

  • Possible precedence issue with control flow operator (%s)

This warning now mentions the name of the control flow operator that triggered the diagnostic (e.g. return, exit, die, etc).

It also covers more cases: Previously, the warning was only triggered if a low-precedence logical operator (like and, or, xor) was involved. Now it is also shown for misleading code like this:

exit $x ? 0 : 1;  # actually parses as: exit($x) ? 0 : 1;
exit $x == 0;     # actually parses as: exit($x) == 0;
  • Use of uninitialized value%s

This warning is now slightly more accurate in cases involving length, pop, shift, or splice:

my $x;
length($x) == 0
# Before:
#  Use of uninitialized value $x in numeric eq (==) at ...
# Now:
#  Use of uninitialized value length($x) in numeric eq (==) at ...

That is, the warning no longer implies that $x was used directly as an operand of ==, which it wasn't.

Similarly:

my @xs;
shift @xs == 0
# Before:
#  Use of uninitialized value within @xs in numeric eq (==) at ...
# Now:
#  Use of uninitialized value shift(@xs) in numeric eq (==) at ...

This is more accurate because there never was an undef within @xs as the warning implied. (The warning for pop works analogously.)

Finally:

my @xs = (1, 2, 3);
splice(@xs, 0, 0) == 0
# Before:
#  Use of uninitialized value within @xs in numeric eq (==) at ...
# Now:
#  Use of uninitialized value in numeric eq (==) at ...

That is, in cases where splice returns undef, it no longer unconditionally blames its first argument. This was misleading because splice can return undef even if none of its arguments contain undef.

[GH #21930 <https://github.com/Perl/perl5/issues/21930>]

  • Old package separator "'" deprecated

Prevent this warning appearing spuriously when checking the heuristic for the You need to quote "%s" warning.

[GH #22145 <https://github.com/Perl/perl5/issues/22145>]


πŸ› οΈ Configuration and Compilation πŸ› οΈ

  • microperl, long broken and of unclear present purpose, has been removed as promised in Perl 5.18. (rip bestie, you were promised this ages ago 🫢)
  • Fix here-doc used for code to probe LC_ALL syntax for disparate locales introduced in 5.39.2. [GH #21451 <https://github.com/Perl/perl5/issues/21451>]
  • You can now separately enable high water mark checks for non-DEBUGGING or disable them for DEBUGGING builds with -Accflags=-DPERL_USE_HWM or -Accflags=-DPERL_NO_HWM respectively. The default remains the same. [GH #16607 <https://github.com/Perl/perl5/issues/16607>]

πŸ§ͺ TESTING πŸ§ͺ

bestie, the test suite got a whole glow-up this release. tests were added and changed to reflect all the other additions and changes, and on top of that, these significant changes happened:

  • Update nm output parsing for Darwin in t/porting/libperl.t to handle changes in the output of nm on Darwin. [GH #21117 <https://github.com/Perl/perl5/issues/21117>]
  • t/op/magic.t would fail when ps was the BusyBox implementation, since that doesn't support the -p flag and otherwise ignores a process id on the command-line. This caused TEST failures on BusyBox systems such as Alpine Linux. [GH #17542 <https://github.com/Perl/perl5/issues/17542>]
  • porting/globvar.t now uses the more portable nm -P ... to fetch the names defined in an object file. The parsing of the names found in the object is now separated from processing them to handle the duplication between local and global definitions on AIX. [GH #21637 <https://github.com/Perl/perl5/issues/21637>]
  • A test was added to lib/locale_threads.t that extensively stress tests locale handling. It turns out that the libc implementations on various platforms have bugs in this regard, including Linux, Windows, *BSD derivatives including Darwin, and others. Experimental versions of this test have been used in the past few years to find bugs in the Perl implementation and in those platforms, as well as to develop workarounds in the Perl implementation, where feasible, for the platform bugs. Multiple bug report tickets have been filed against platforms, and some have been fixed. The test checks that platforms that purport to support thread-safe locale handling actually do so (and that perl works properly on those that do; The read-only variable ${^SAFE_LOCALES} is set to 1 if perl thinks the platform can handle this, whatever the platform's documentation says).

Also tested for is if the various locale categories can indeed be set independently to disparate locales. (An example of where you might want to do this is if you are a Western Canadian living and working in Holland. You likely will want to have the LC_MONETARY locale be set to where you are living, but have the other parts of your locale retain your native English values. Later, as you get a bit more comfortable with Dutch, and in order to communicate better with your colleagues, you might want to change LC_TIME and LC_NUMERIC to Dutch, while leaving LC_CTYPE and LC_COLLATE set to English indefinitely.)

  • The test t/porting/libperl.t will no longer run in maint releases. This test is sensitive to changes in the output of nm on various platforms, and tarballs aren't updated as we update this test in blead. [GH #21677 <https://github.com/Perl/perl5/issues/21677>]

🌍 PLATFORM SUPPORT 🌍

✨ New Platforms ✨

  • Serenity OS β€” Out of the box support for Serenity OS was added. she's new here and she's thriving πŸ¦‹

πŸ› οΈ Platform-Specific Notes πŸ› οΈ

Windows

heads up bestie: Visual Studio 2013 is out. she's not coming to the build party anymore. πŸ’€

Linux

  • The hints file has been updated to handle the Intel oneAPI DPC++/C++ compiler.

MacOS/Darwin

VMS

  • Fixed the configure "installation prefix" prompt to accept a string rather than yes/no.
  • Fixed compilation by defining proper value for perl_lc_all_category_positions_init.
  • Increased buffer size when reading config_H.SH to fix compilation under clang.

Oracle Developer Studio (Solaris, Oracle Linux)


πŸ”§ INTERNAL CHANGES πŸ”§

  • PERL_RC_STACK build option added.

This new build option is highly experimental and is not enabled by default. Perl can be built with it by using the Configure option -Accflags='-DPERL_RC_STACK'.

It makes the argument stack bump the reference count of SVs pushed onto it. It is mostly functional, but currently slow and incomplete.

It is intended in the long term that this build option will become the default option, and then finally the only option; but this will be many releases away.

In particular, there is currently no support within XS code for using these new features. So under this build option, all XS functions are called via a backwards-compatibility wrapper which slows down such calls.

In future releases, better support for XS code is intended to be added. It is expected that straightforward XS code will eventually be able to make use of a reference-counted stack without modification, with any heavy lifting being handled by the XS compiler (xsubpp) and the macros which it outputs. But code which implements PP() functions will eventually have to be modified to use a new PP API: rpp_foo() rather than PUSHs() etc. But this new API is not yet stable, nor has it yet been back-ported via Devel::PPPort.

See perlguts for more details.

  • A new API function has been added that simplifies C (or XS) code that creates LISTOP optree fragments. newLISTOPn() is a variadic function that takes a NULL-terminated list of child op pointers, and constructs a new checked LISTOP to contain them all. This is simpler than creating a new plain OP_LIST, adding each child individually, and finally calling op_convert_list() in most code fragments. iconic API behaviour, honestly ✨
  • The eval_sv() API now accepts the G_USEHINTS flag, which uses the hints such as strict and features from PL_curcop instead of the default, which is to use default hints, e.g. no use vX.XX;, no strict, default features.
Beware if you use this flag in XS code: your evaluated code will need to support whatever strictness or features are in effect at the point your XS function is called.

[GH #21415 <https://github.com/Perl/perl5/issues/21415>]

  • PERL_VERSION_LE has been fixed to properly check for "less than or equal" rather than "less than". πŸ’…
  • dAX, dITEMS and hence dXSARGS now declare AX and items as Stack_off_t rather than SSize_t. This reverts back to compatibility with pre-64-bit stack support for default builds of perl where Stack_off_t is I32. [GH #21782 <https://github.com/Perl/perl5/issues/21782>]
  • A new function is now available to XS code, sv_langinfo in perlapi. This provides the same information as the existing Perl_langinfo8 in perlapi, but returns an SV instead of a char *, so that programmers don't have to concern themselves with the UTF-8ness of the result. This new function is now the preferred interface for XS code to the nl_langinfo(3) libc function. From Perl space, this information continues to be provided by the I18N::Langinfo module. πŸŽ€
  • glibc has an undocumented equivalent function to querylocale(), which our experience indicates is reliable. When this is function is used, it removes the need for perl to keep its own records, hence is more efficient and guaranteed to be accurate. Use of this function can be disabled by defining the NO_NL_LOCALE_NAME build option

✨ Selected Bug Fixes ✨

okay bestie, sit down, hydrate, this is the big long list of "we fixed the thing" and honestly? it ate πŸ’…

  • The delimiter pair SYRIAC COLON SKEWED LEFT/RIGHT got removed from the ones that the extra_paired_delimiters feature recognizes. (go peep "Quote and Quote-like Operators" in perlop for the full lore.) Why? Because those characters are normally written right-to-left, and that could be visually confusing, no cap [GH #22228 <https://github.com/Perl/perl5/issues/22228>]. The change was actually to forbid any right-to-left delimiters, but this pair is literally the only current instance that meets that criterion. And by policy, this means the extra_paired_delimiters feature cannot be considered to have been stable long enough for its experimental status to be removed. the drama 😭
  • use 5.36; or later didn't enable the post parse reporting of Name "%s::%s" used only once: possible typo warnings when enabling warnings. [GH #21271 <https://github.com/Perl/perl5/issues/21271>]
  • Fixed a crash or assertion when cleaning up a closure that refers to an outside our sub. [GH #21067 <https://github.com/Perl/perl5/issues/21067>]
  • Fixed a number of issues where I32 was used as a string offset or size rather than SSize_t or STRLEN/size_t [GH #21012 <https://github.com/Perl/perl5/issues/21012>]
  • ~$str when $str was more than 2GB in size would do nothing or produce an incomplete result. nothing?? embarrassing.
  • String repeat, $str x $count, didn't handle $str over 2GB in size, throwing an error. Now such strings are repeated. πŸŽ€
  • Complex substitution after the 2GB point in a string could access incorrect or invalid offsets in the string.
  • sv_utf8_decode() would truncate the SV's pos() value. This wasn't visible via utf8::decode().
  • When compiling a constant folded hash key, the length was truncated when creating the shared SV. Since hash keys over 2GB are not supported, throw a compilation error instead.
  • msgrcv() incorrectly called get magic on the buffer SV and failed to call set magic on completion. [GH #21012 <https://github.com/Perl/perl5/issues/21012>]
  • msgrcv() used the size parameter to resize the buffer before validating it. [GH #21012 <https://github.com/Perl/perl5/issues/21012>]
  • Inheriting from a class that was hierarchically an ancestor of the new class, eg. class A::B :isa(A) { ... }, would not attempt to load the parent class. [GH #21332 <https://github.com/Perl/perl5/issues/21332>]
  • Declared references can now be used with state variables. slay [GH #21351 <https://github.com/Perl/perl5/issues/21351>]
  • Trailing elements in an unshifted and resized array will now always be initialized. [GH #21265 <https://github.com/Perl/perl5/issues/21265>]
  • Make use 5.036 respect the -X flag

perl's -X flag disables all warnings globally, but Β«use 5.036Β» didn't respect that until now. [GH #21431 <https://github.com/Perl/perl5/issues/21431>]

  • Fixed an OP leak when an error was produced for initializer for a class field. [GH #20812 <https://github.com/Perl/perl5/issues/20812>]
  • Fixed a leak of the return value when smartmatching against a code reference.
  • Fixed a slowdown in repeated substitution replacements using special variables, such as s/....x$1/g. It actually makes all string concatenations involving such "magic" variables less slow, but the slowdown was more noticeable on repeated substitutions due to extra memory usage that was only freed after the last iteration. The slowdown started in perl 5.28.0 - which generally sped up string concatenation but slowed down when using special variables. [GH #21360 <https://github.com/Perl/perl5/issues/21360>]
  • Lexical names from the enclosing scope in a lexical sub or closure weren't visible to code executed by calling eval EXPR; from the DB package. This was introduced in 5.18 in an attempt to prevent subs from retaining a reference to their outer scope, but this broke the special behaviour of eval EXPR; in package DB.

This incidentally fixed a TODO test for B::Deparse. [GH #19370 <https://github.com/Perl/perl5/pull/19370>]

  • Optionally support an argument stack over 2**32 entries on 64-bit platforms. This requires 32GB of memory just for the argument stack pointers itself, so you will require a significantly more memory to take advantage of this. 32GB just for pointers bestie 🫠

To enable this add -Accflags=-DPERL_STACK_OFFSET_SSIZET or equivalent to the Configure command-line.

[GH #20917 <https://github.com/Perl/perl5/issues/20917>] [GH #21523 <https://github.com/Perl/perl5/issues/21523>]

  • Fixed various problems with join() where modifications to the separator could be handled inconsistently, or could access released memory. Changes to the separator from magic or overloading for values in the LIST no longer have an effect on the resulting joined string. [GH #21458 <https://github.com/Perl/perl5/issues/21458>]
  • Don't clear the integer flag IOK from lines in the @{"_<$sourcefile"} array when a dbstate op is removed for that line. This was broken when fixing [GH #19198 <https://github.com/Perl/perl5/issues/19198>]. [GH #21564 <https://github.com/Perl/perl5/issues/21564>]
  • Many bug fixes have been made for using locales under threads and in embedded perls. And workarounds for libc bugs have been added. As a result thread-safe locale handling is now the default under OpenBSD, and MingW when compiled with UCRT.

However, testing has shown that Darwin's implementation of thread-safe locale handling has bugs. So now Perl doesn't attempt to use the thread-safe operations when compiled on Darwin.

As before, you can check to see if your program is running with thread-safe locales by checking if the value of ${^SAFE_LOCALES} is 1.

  • Various bugs have been fixed when perl is configured with -Accflags=-DNO_LOCALE_NUMERIC or any other locale category (or categories).
  • Not all locale categories need be set to the same locale. Perl now works around bugs in the libc implementations of locale handling on some platforms that previously could result in mojibake. mojibake jumpscare 😭
  • LC_ALL is represented in one of two ways when not all locale categories are set to the same locale. On some platforms, such as Linux and Windows, the representation is of the form of a series of 'category=locale-name' pairs. On other platforms, such as *BSD, the representation is positional like name1 / name2 / ... . name1 is always for a particular category as defined by the platform, as are the other names. The sequence that separates the names (the " / " above) also varies by platform. Previously, perl had problems with platforms that used the positional notation. This is now fixed.
  • A bug has been fixed in the regexp engine with an optimisation that applies to the + quantifier where it was followed by a (*SKIP) pattern.

[GH #21534 <https://github.com/Perl/perl5/issues/21534>]

  • The tmps (mortal) stack now grows exponentially. Previously it grew linearly, so if it was growing incrementally, such as through many calls to sv_2mortal(), on a system where realloc() is O(size), the performance would be O(n*n). With exponential grows this changes to amortized O(n). [GH #21654 <https://github.com/Perl/perl5/issues/21654>]
  • Lexical subs now have a new stub in the pad for each recursive call into the containing function. This fixes two problems:
    • If the lexical sub called the containing function, a Can't undef active subroutine error would be thrown. For example:
use v5.36.0;
sub outer($oc) {
    my sub inner ($c) {
         outer($c-1) if $c; # Can't undef active subroutine
    }
    inner($oc);
}
outer(2);

[GH #18606 <https://github.com/Perl/perl5/issues/18606>]

  • If the lexical sub was called from a recursive call into the containing function, this would overwrite the bindings to the closed over variables in the lexical sub, so calls into the lexical sub from the outer recursive call would have access to the variables from the inner recursive call:
use v5.36.0;
sub outer ($x) {
    my sub inner ($label) {
        say "$label $x";
    }
    inner("first");
    outer("inner") if $x eq "outer";
    # this call to inner() sees the wrong $x
    inner("second");
}
outer("outer");

[GH #21987 <https://github.com/Perl/perl5/issues/21987>]

  • prepare_export_lexical() was separately saving PL_comppad and PL_curpad, this could result in PL_curpad being restored to a no longer valid value, resulting in a panic when importing lexicals in some cases. [GH #21981 <https://github.com/Perl/perl5/issues/21981>]
  • A string eval() operation in the scope of a use VERSION declaration would sometimes emit spurious Downgrading a use VERSION declaration warnings due to an inconsistency in the way the version number was stored. This is now fixed. [GH #22121 <https://github.com/Perl/perl5/issues/22121>]

🌸 Known Problems 🌸

  • perlivp is missing streamzip on Windows

The streamzip utility does not get installed on Windows but should get installed.

πŸ¦‹ Errata From Previous Releases πŸ¦‹

  • perl5300delta has been updated to include the removal of the arybase module that happened at the same time as the removal of $[.

πŸ’– ACKNOWLEDGEMENTS πŸ’–

okay bestie, this is the part where we give credit where credit is so due, because none of this happened by magic πŸ’«

Perl 5.40.0 represents approximately 11 months of development since Perl 5.38.0 and contains approximately 160,000 lines of changes across 1,500 files from 75 authors. not me getting emotional over a version number 😭

Excluding auto-generated files, documentation and release tools, there were approximately 110,000 lines of changes to 1,200 .pm, .t, .c and .h files. the way that's a whole city of code fr fr πŸ™οΈ

Perl continues to flourish into its fourth decade thanks to a vibrant community of users and developers. The following people are known to have contributed the improvements that became Perl 5.40.0:

Abe Timmerman, Alexander Kanavin, Amory Meltzer, Aristotle Pagaltzis, Arne Johannessen, Beckett Normington, Bernard Quatermass, Bernd, Bruno Meneguele, Chad Granum, Chris 'BinGOs' Williams, Christoph Lamprecht, Craig A. Berry, Dagfinn Ilmari MannsΓ₯ker, Dan Book, Dan Church, Daniel BΓΆhmer, Dan Jacobson, Dan Kogai, David Golden, David Mitchell, E. Choroba, Elvin Aslanov, Erik Huelsmann, Eugen Konkov, Gianni Ceccarelli, Graham Knop, Greg Kennedy, guoguangwu, Hauke D, H.Merijn Brand, Hugo van der Sanden, iabyn, Jake Hamby, Jakub Wilk, James E Keenan, James Raspass, Joe McMahon, Johan Vromans, John Karr, Karen Etheridge, Karl Williamson, Leon Timmermans, Lukas Mai, Marco Fontani, Marek Rouchal, Martijn Lievaart, Mathias Kende, Matthew Horsfall, Max Maischein, Nicolas Mendoza, Nicolas R, OpossumPetya, Paul Evans, Paul Marquess, Peter John Acklam, Philippe Bruhat (BooK), Raul E Rangel, Renee Baecker, Ricardo Signes, Richard Leach, Scott Baker, Sevan Janiyan, Sisyphus, Steve Hay, TAKAI Kousuke, Todd Rinaldo, Tomasz Konojacki, Tom Hughes, Tony Cook, William Lyu, x-yuri, Yves Orton, Zakariyya Mughal, Дилян ΠŸΠ°Π»Π°ΡƒΠ·ΠΎΠ².

πŸ‘‘ every single one of y'all, iconic.

The list above is almost certainly incomplete as it is automatically generated from version control history. In particular, it does not include the names of the (very much appreciated) contributors who reported issues to the Perl bug tracker.

so if you filed a bug and you're not on the list β€” we see you, we appreciate you, you're valid 🫢 the script just can't read the bug tracker's mind.

Many of the changes included in this version originated in the CPAN modules included in Perl's core. We're grateful to the entire CPAN community for helping Perl to flourish. 🌸

For a more complete list of all of Perl's historical contributors, please see the AUTHORS file in the Perl source distribution.


πŸ› REPORTING BUGS πŸ›

If you find what you think is a bug, you might check the perl bug database at https://github.com/Perl/perl5/issues. There may also be information at https://www.perl.org/, the Perl Home Page. πŸ‘€

If you believe you have an unreported bug, please open an issue at https://github.com/Perl/perl5/issues. Be sure to trim your bug down to a tiny but sufficient test case β€” yes, the tiny part matters, bestie, nobody can debug your entire 4,000-line app πŸ’€

If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see "SECURITY VULNERABILITY CONTACT INFORMATION" in perlsec for details of how to report the issue. do not drop a zero-day in a public issue, please and thank you πŸ™ˆ


🫢 GIVE THANKS 🫢

If you wish to thank the Perl 5 Porters for the work we had done in Perl 5, you can do so by running the perlthanks program:

perlthanks

This will send an email to the Perl 5 Porters list with your show of thanks. πŸ’Œ genuinely the nicest thing you can do for a maintainer, no cap.


πŸ‘€ SEE ALSO πŸ‘€

  • The Changes file for an explanation of how to view exhaustive details on what changed.
  • The INSTALL file for how to build Perl.
  • The README file for general stuff.
  • The Artistic and Copying files for copyright information.

and that's a wrap on the whole page, bestie πŸŽ€ this lore came straight from perl v5.42.3, dated 2026-08-03 β€” go forth and perlthanks somebody, they deserve it πŸ’…βœ¨

πŸ“¦ where this page comes from