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 (Saint) 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