Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How do I get an array which is the logical AND of the elements of two other arrays?

by ayrnieu (Beadle)
on Feb 25, 2006 at 23:00 UTC ( [id://532817]=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://532817]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found