all#
True if the block returns true for every element (including empty list).
תקציר#
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“).
מה מוחזר#
1 if every element satisfied the block, 0 otherwise.
דוגמאות#
die "found empty string" unless all { length } @strings;
my $ready = all { $_->is_ready } @workers;
my $yes = all { $_ > 0 } (); # 1 - vacuous truth
הבדלים מן ה-upstream#
Fully compatible with upstream.
ראו גם#
any- require at least one match.notall- inverse: at least one failure.none- inverse: zero matches.