Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: get the Difference between two arrays

by davido (Cardinal)
on Apr 02, 2018 at 18:53 UTC ( #1212194=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
     my (@union, @intersection, @difference);
        my %count = ();
    ...
            push @union, $element;
            push @{ $count{$element} > 1 ? \@intersection : \@difference }
    +, $element;
        }
    
  2. or download this
    sub difference {
        my $array_ref1 = shift;
    ...
        }
        return \@difference;
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2021-06-22 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (108 votes). Check out past polls.

    Notices?