in reply to How do I get an array which is the logical AND of the elements of two other arrays?

my @C = List::Compare->new(qw/-u -a/, \@A, \@B)->get_intersection;

Updated: and now that I actually read your code, I notice this problem:

my @A = [ '1', '2', '4', '8' ]; my @B = [ '1', '3', '6', '8' ];

The [...] you have here almost certainly isn't what you want. Try one of

my @a = qw/1 2 4 8/; my $a = [qw/1 2 4 8/]; # an arrayref
  • Comment on Re: How do I get an array which is the logical AND of the elements of two other arrays?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: How do I get an array which is the logical AND of the elements of two other arrays?
by ibanix (Hermit) on Mar 02, 2006 at 05:17 UTC
    List::Compare was exactly what I wanted, thank you!
    $ echo '$0 & $0 &' > foo; chmod a+x foo; foo;