From fd64c88862b372c999c9f1f30b1e0a1c2d644be0 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Mon, 25 Nov 2024 21:21:51 +0000 Subject: [PATCH] perldelta for any() + all() --- pod/perldelta.pod | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 3c162e56d5a0..d53738408312 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -41,6 +41,31 @@ similar to the way that C<:reader> already creates reader accessors. my $p = Point->new( x => 20, y => 40 ); $p->set_x(60); +=head2 New C and C operators + +A new experimental feature has been added, which adds two new list-processing +operators, C and C. + + use v5.40; + use feature 'all'; + + my @numbers = ... + + if(all { $_ % 2 == 0 } @numbers) { + say "All the numbers are even"; + } + +These operate similarly to C 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 L 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. + =head1 Security XXX Any security-related notices go here. In particular, any security