scalar ( grep { $_ ne x && $_ ne y && $_ ne z } @arr )
只是想知道如果我们在perl中有“IN”和“NOT IN”类似sql的操作符,这不会更容易
scalar ( grep { $_ NOT IN (x,z) } @arr )
还是有一个已经?
谢谢,三位一体
my %set = map {$_ => 1} qw( x y z ); # add x,y and z to the hash as keys # each with a value of 1 my @not_in_set = grep {not $set{$_}} @arr;