in reply to Check if at least one element of array is bigger than X
any is efficient in the sense that the function will return as soon as the condition is met; it will not loop through the entire array if it does not have to. This is similar to the last solution above.use strict; use warnings; use List::MoreUtils qw(any); my @array = (34,52,67,3,66); print "At least one value > 10" if any { $_ > 10 } @array; __END__ At least one value > 10
|
|---|