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 KurtZ (Friar)
on Apr 02, 2018 at 18:26 UTC ( #1212190=note: print w/replies, xml ) Need Help??


in reply to get the Difference between two arrays

Use hash slices to create hashes and delete via hash slice. See Perl faq for a conventional solution.
  • Comment on Re: get the Difference between two arrays

Replies are listed 'Best First'.
Re^2: get the Difference between two arrays
by LanX (Cardinal) on Apr 02, 2018 at 19:05 UTC
    > Use hash slices to create hashes and delete via hash slice.

    like this Using hashes for set operations... ? :)

    update

    use strict; use warnings; use Data::Dump qw/pp dd/; my @Llist = qw(abel abel baker camera delta edward fargo golfer); my @Rlist = qw(baker camera delta delta edward fargo golfer hilton); my %tmp; @tmp{@Rlist} = @Rlist; delete @tmp{@Llist}; pp values %tmp;
    "hilton"

    please note this is restricted to keys with different string representation.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2021-06-25 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (133 votes). Check out past polls.

    Notices?