in reply to How do I get an array which is the logical AND of the elements of two other arrays?
List::Compare may well be what you are looking for - reinventing wheels and all that.
use warnings; use strict; use Data::Dump::Streamer; use List::Compare; my @A = ('1', '2', '4', '8'); my @B = ('1', '3', '6', '8'); my $lc = List::Compare->new (\@A, \@B); my @intersect = $lc->get_intersection; my @AOnly = $lc->get_Lonly; my @BOnly = $lc->get_Ronly; print "Intersection: @intersect\n"; print "A only: @AOnly\n"; print "B only: @BOnly\n";
Prints:
Intersection: 1 8 A only: 2 4 B only: 3 6
|
|---|