1、数组里是否含有元素
if (grep { $_ eq $panel } @panel_list){
print"True\n";
}
2、perl中对数组字符串取交集,并集,差集
参考:https://metacpan.org/pod/Array::Utils
use Array::Utils qw(:all);
my @a = qw( a b c d );
my @b = qw( c d e f );
# symmetric difference 取差集
my @diff = array_diff(@a, @b);
# intersection 取交集
my @isect = intersect(@a, @b);
# unique union 取并集
my @unique = unique(@a, @b);
# check if arrays contain same members
if ( !array_diff(@a, @b) ) {
# do something
}
# get items from array @a that are not in array @b
my @minus = array_minus( @a, @b );