NAME
perldelta - what is new for perl v5.41.7
DESCRIPTION
This document describes differences between the 5.41.6 release and the 5.41.7 release.
If you are upgrading from an earlier release such as 5.41.5, first read perl5416delta, which describes differences between 5.41.5 and 5.41.6.
Core Enhancements
New :writer
attribute on field variables
Classes defined using use feature 'class'
are now able to automatically create writer accessors for scalar fields, by using the :writer
attribute, similar to the way that :reader
already creates reader accessors.
class Point {
field $x :reader :writer :param;
field $y :reader :writer :param;
}
my $p = Point->new( x => 20, y => 40 );
$p->set_x(60);
New any
and all
operators
A new experimental feature has been added, which adds two new list-processing operators, any
and all
.
use v5.40;
use feature 'all';
my @numbers = ...
if(all { $_ % 2 == 0 } @numbers) {
say "All the numbers are even";
}
These operate similarly to grep
except that they only ever return true or false, testing if any (or all) of the elements in the list make the testing block yield true. Because of this they can short-circuit, avoiding the need to test any further elements if a given element determines the eventual result.
These are inspired by the same-named functions in the List::Util module, except that they are implemented as direct core operators, and thus perform faster, and do not produce an additional subroutine call stack frame for invoking the code block.
Performance Enhancements
Code that uses the
indexed
function from the builtin module to generate a list of index/value pairs out of an array or list which is then passed into a two-variableforeach
list to unpack those again is now optimised to be more efficient.my @array = (...); foreach my ($idx, $val) (builtin::indexed @array) { ... }
foreach my ($idx, $val) (builtin::indexed LIST...) { ... }
In particular, a temporary list twice the size of the original is no longer generated. Instead, the loop iterates down the original array or list in-place directly, in the same way that
foreach (@array)
orforeach (LIST)
would do.
Modules and Pragmata
Updated Modules and Pragmata
B::Deparse has been upgraded from version 1.80 to 1.81.
builtin has been upgraded from version 0.016 to 0.017.
CPAN::Meta::YAML has been upgraded from version 0.018 to 0.020.
feature has been upgraded from version 1.92 to 1.93.
IO::Socket::IP has been upgraded from version 0.42 to 0.43.
Module::CoreList has been upgraded from version 5.20241120 to 5.20241220.
Opcode has been upgraded from version 1.66 to 1.67.
parent has been upgraded from version 0.242_001 to 0.244.
warnings has been upgraded from version 1.71 to 1.72.
XS::APItest has been upgraded from version 1.38 to 1.40.
Documentation
Changes to Existing Documentation
We have attempted to update the documentation to reflect the changes listed in this document. If you find any we have missed, open an issue at https://github.com/Perl/perl5/issues.
Additionally, the following selected changes have been made:
perl5416delta
pod/perlguts.pod and pod/perlclib.pod
- Memory Allocation in C/XS
-
Documentation was updated to reflect that mixing
Newx
,Renew
, andSafefree
vsmalloc
,realloc
, andfree
are not allowed, and mixing pointers between the 2 classes of APIs is not allowed. Updates made in pod/perlguts.pod and pod/perlclib.pod.
- Added the change note for apostrophes in names being reinstated, which was delayed by the review cycle.
Configuration and Compilation
The (mostly undocumented) configuration macro
PERL_STRICT_CR
has been removed. When enabled (e.g. with./Configure -A ccflags=-DPERL_STRICT_CR
), it would make the perl parser throw a fatal error when it encountered a CR (carriage return) character in source files. The default (and now only) behavior of the perl parser is to strip CRs paired with newline characters and otherwise treat them as whitespace.(
PERL_STRICT_CR
was originally introduced in perl 5.005 to optionally restore backward compatibility with perl 5.004, which had made CR in source files an error. Before that, CR was accepted, but retained literally in quoted multi-line constructs such as here-documents, even at the end of a line.)Similarly, the (even less documented) configuration macro
PERL_CR_FILTER
has been removed. When enabled, it would install a default source filter to strip carriage returns from source code before the parser proper got to see it.
Testing
Tests were added and changed to reflect the other additions and changes in this release.
Internal Changes
New API functions are introduced to convert strings encoded in UTF-8 to their ordinal code point equivalent. These are safe to use by default, and generally more convenient to use than the existing ones.
"
utf8_to_uv
" in perlapi and "utf8_to_uv_or_die
" in perlapi replace "utf8_to_uvchr
" in perlapi (which is retained for backwards compatibility), but you should convert to use the new forms, as likely you aren't using the old one safely.To convert in the opposite direction, you can now use "
uv_to_utf8
" in perlapi. This is not a new function, but a new synonym for "uvchr_to_utf8
" in perlapi. It is added so you don't have to learn two sets of names.There are also two new functions, "
strict_utf8_to_uv
" in perlapi and "c9strict_utf8_to_uv
" in perlapi which do the same thing except when the input string represents a code point that Unicode doesn't accept as legal for interchange, using either the strict original definition (strict_utf8_to_uv
), or the looser one given by Unicode Corrigendum #9 (c9strict_utf8_to_uv
). When the input string represents one of the restricted code points, these functions return the UnicodeREPLACEMENT CHARACTER
instead.Also "
extended_utf8_to_uv
" in perlapi is a synonym forutf8_to_uv
, for use when you want to emphasize that the entire range of Perl extended UTF-8 is acceptable.There are also replacement functions for the three more specialized conversion functions that you are unlikely to need to use. Again, the old forms are kept for backwards compatibility, but you should convert to use the new forms.
"
utf8_to_uv_flags
" in perlapi replaces "utf8n_to_uvchr
" in perlapi."
utf8_to_uv_errors
" in perlapi replaces "utf8n_to_uvchr_error
" in perlapi."
utf8_to_uv_msgs
" in perlapi replaces "utf8n_to_uvchr_msgs
" in perlapi.Also added are the inverse functions "
uv_to_utf8_flags
" in perlapi and "uv_to_utf8_msgs
" in perlapi, which are synonyms for the existing functions, "uvchr_to_utf8_flags
" in perlapi and "uvchr_to_utf8_flags_msgs
" in perlapi respectively. These are provided only so you don't have to learn two sets of names.Three new API functions are introduced to convert strings encoded in UTF-8 to native bytes format (if possible). These are easier to use than the existing ones, and they avoid unnecessary memory allocations. The functions are "
utf8_to_bytes_overwrite
" in perlapi which is used when it is ok for the input string to be overwritten with the converted result; and "utf8_to_bytes_new_pv
" in perlapi and "utf8_to_bytes_temp_pv
" in perlapi when the original string must be preserved intact.utf8_to_bytes_temp_pv
returns the result in a temporary using perlapi/SAVEFREEPV
that will automatically be destroyed. Withutf8_to_bytes_new_pv
, you are responsible for freeing the newly allocated memory that is returned if the conversion is successful.The latter two functions are designed to replace "
bytes_from_utf8
" in perlapi which creates memory unnecessarily, or unnecessarily large.New API functions
valid_identifier_pve()
,valid_identifier_pvn()
andvalid_identifier_sv()
have been added, which test if a string would be considered by Perl to be a valid identifier name.When assigning from an SVt_IV into a SVt_NV (or vice versa), providing that both are "bodyless" types, Perl_sv_setsv_flags will now just change the destination type to match the source type. Previously, an SVt_IV would have been upgraded to a SVt_PVNV to store an NV, and an SVt_NV would have been upgraded to a SVt_PVIV to store an IV. This change prevents the need to allocate - and later free - the relevant body struct.
Selected Bug Fixes
Declaring a lexically scoped array or hash using
state
within a subroutine and then immediately returning no longer triggers a "Bizarre copy of HASH/ARRAY in subroutine exit" error. [GH #18630]builtin::trim()
didn't properly clearTARG
which could result in out of date cached numeric versions of the value being used on a second evaluation. Properly clear any cached values. [GH #22784]
Acknowledgements
Perl 5.41.7 represents approximately 4 weeks of development since Perl 5.41.6 and contains approximately 11,000 lines of changes across 160 files from 16 authors.
Excluding auto-generated files, documentation and release tools, there were approximately 6,400 lines of changes to 96 .pm, .t, .c and .h files.
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.41.7:
Dagfinn Ilmari Mannsåker, Daniel Dragan, Ed Sabol, James E Keenan, Karen Etheridge, Karl Williamson, Lukas Mai, Mark Fowler, Max Maischein, Paul Evans, Richard Leach, Scott Baker, Sisyphus, TAKAI Kousuke, Thibault Duponchelle, Tony Cook.
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.
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.
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.
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.
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.