all#
True if the block returns true for every element (including empty list).
Synopsis#
my $bool = all { BLOCK } @list;
if ( all { defined } @values ) { ... }
For each element all sets $_ to that element and calls the
block in scalar context. It returns false as soon as the block
returns false for any element. An empty list yields true (the
conventional “vacuous truth”).
What you get back#
1 if every element satisfied the block, 0 otherwise.
Examples#
die "found empty string" unless all { length } @strings;
my $ready = all { $_->is_ready } @workers;
my $yes = all { $_ > 0 } (); # 1 — vacuous truth
Differences from upstream#
Fully compatible with upstream.
See also#
any— require at least one match.notall— inverse: at least one failure.none— inverse: zero matches.