Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: comparing two array

by dorko (Parson)
on Jun 17, 2009 at 15:47 UTC ( #772445=note: print w/ replies, xml ) Need Help??


in reply to comparing two array

I like List::Compare for things like this. From the docs:

use strict; use warnings; use List::Compare; my @Llist = qw(abel abel baker camera delta edward fargo golfer) +; my @Rlist = qw( baker camera delta delta edward fargo golfer +hilton); my $lc = List::Compare->new(\@Llist, \@Rlist); my @intersection = $lc->get_intersection; print join ", ", @intersection; # Results: # baker, camera, delta, edward, fargo, golfer
Of course, either of those two lists could consist of only one item.

Cheers,

Brent

-- Yeah, I'm a Delt.


Comment on Re: comparing two array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-07-04 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls