Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
"be consistent"
 
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 exploiting the Monastery: (8)
As of 2014-04-19 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (475 votes), past polls