Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: compare 2 arrays for intersect diff and commmon values

by tangent (Vicar)
on Mar 25, 2014 at 04:56 UTC ( #1079635=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %count = ();
    foreach my $device (@current_list, @temp_devicelist) {
        $count{$device}++;
    }
    
  2. or download this
    my %count;
    # ...
    ...
    my @difference = grep { $count{$_} == 1 } keys %count;
    my @intersect  = grep { $count{$_} == 2 } keys %count;
    my @union      = keys %count;
    
  3. or download this
    print "Difference:\n";
    print "$_\n" for @difference;
    ...
    print "$_\n" for @intersect;
    print "Union:\n";
    print "$_\n" for @union;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-08-12 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?