largeQ
这是经典的集合差运算,下面的代码还演示了集合并集、交集的运算,只是没有输出结果,请自行理解,完整代码如下:@a=('1','2','3','4');@b=('1','3');@union=();#并集@diff=(); #差集@isect=();#交集foreach $e(@a,@b){$union{$e}++&&$isect{$e}++;}@union=keys %union;@isect=keys %isect;@diff=grep {$union{$_}==1;} @union;print join(',', @a),"\n";print join(',', @b),"\n";print join(',', @diff),"\n";