Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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.


Comment on Re: Combining arrays with grep/unless?
Select or Download Code

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 romping around the Monastery: (5)
As of 2015-07-02 06:42 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 (30 votes), past polls