Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: compare 2 arrays for intersect diff and commmon values

by tangent (Parson)
on Mar 25, 2014 at 04:56 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-24 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found