Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Combining arrays with grep/unless?

by dorko (Parson)
on Feb 09, 2007 at 23:24 UTC ( #599300=note: print w/replies, xml ) Need Help??


in reply to Combining arrays with grep/unless?

List::Compare was built for working with two, three or more arrays at once.

use List::Compare; my @Llist = ('A','B','C','D','E'); my @Rlist = ( 'D','E','F','G','H','I','J'); my $lc = List::Compare->new(\@Llist, \@Rlist); # If I read your post correctly, # this is what you want. my @LorRonly = $lc->get_symmetric_difference; print join ", ", @LorRonly; # Also does... my @intersection = $lc->get_intersection; my @union = $lc->get_union; # And much, much more.
Output:

A, B, C, F, G, H, I, J

Cheers,

Brent

-- Yeah, I'm a Delt.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2016-10-01 21:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (7 votes). Check out past polls.