I think none
subroutine from List::MoreUtils
does not act as described. According to documentation,
none BLOCK LIST Logically the negation of any. Returns a true value if no item in LIST meets the criterion given through BLOCK, or if LIST is empty. Sets $_ for each item in LIST in turn
Now, try:
use strict;
use warnings;
use 5.012;
use List::MoreUtils qw(none);
my @arr = ( 1, 2, 3 );
if ( none { $_ == 5 } @arr ) {
say "none of the elements in arr equals 5";
}
else {
say "some element in arr equals 5";
}
works OK, but replace @arr
with an empty one (my @arr = ();
or simply my @arr;
) and you get a wrong answer.
What's going on?
update: i had List::MoreUtils ver 0.22. Updated to the latest and it seems OK. Weird though!