A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://perldoc.perl.org/functions/all below:

all - Perldoc Browser

Evaluates the BLOCK for each element of the LIST (locally setting $_ to each element) and checks the truth of the result of that block. Returns true if every element makes the block yield true, or returns false if at least one element makes the block false.

As soon as any element makes the block yield false, then the result of this operator is determined. It will short-circuit in that case and not consider any further elements.

When used as a condition, this is similar to using grep to count that every value satisfies the condition, except for this short-circuit behaviour.

if( all { length $_ } @strings ) {
    say "Every string is non-empty";
}

is roughly equivalent to

if( @strings == grep { length $_ } @strings ) ...

This operator is only available if the keyword_all feature is enabled.

It is currently considered experimental, and will issue a compile-time warning in the category experimental::all unless that category is silenced.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4