my @A = ("aa","bb");
my @B = ("aa","cc");
与Set的相对补码相同的概念。 (A-B)输出应为“ bb”。我不想只使用Perl的内置功能来使用Perl的任何外部模块。
答案 0 :(得分:2)
my @A = ("aa","bb");
my @B = ("aa","cc");
# make a hash with all the elements of @B as keys
my %B;
@B{@B} = ();
my @complement = grep { ! exists $B{$_} } @A;