any#
True if the block returns true for at least one element.
Σύνοψη#
my $bool = any { BLOCK } @list;
if ( any { length > 10 } @strings ) { ... }
For each element any sets $_ to that element and calls the block in scalar context. It returns true as soon as the block returns true for any element, without examining the rest. For an empty list it returns false.
Τι επιστρέφεται#
1 if any element satisfied the block, 0 otherwise.
Παραδείγματα#
warn "has empty" if any { $_ eq '' } @values;
die "has admin" if any { $_->is_admin } @users;
my $ok = any { /^--help$/ } @ARGV;
Διαφορές από το upstream#
Fully compatible with upstream.
Δείτε επίσης#
all- require every element to match.none- require no element to match.first- return the matching element itself.