in reply to Difference Quantity of two Arrays

I was surprised that this wasn't in CPAN's List::MoreUtils. Seems like this is a fairly common need.

throop

Replies are listed 'Best First'.
Re^2: Difference Quantity of two Arrays
by ikegami (Patriarch) on Jan 02, 2007 at 16:02 UTC

    This is a set operation (set difference), not a list operation.

      This is a set operation (set difference), not a list operation.
      Sure it is a set operation. As is uniq, or even max. You could want to do the same operation to hashkeys, or to a CSV string. But the most common way that the set-difference problem shows up is as the set difference between two lists.

      If not List::MoreUtils, I'm still surprised it isn't in one of the common modules.

      throop

Re^2: Difference Quantity of two Arrays
by dorko (Prior) on Jan 02, 2007 at 17:02 UTC
    List::Compare works for this problem:

    use strict; use warnings; use List::Compare; my @dbs = qw(fetch forward user smtp); my @skip_dbs = qw(user smtp); my $lc = List::Compare->new(\@dbs, \@skip_dbs); my @list = $lc->get_unique; print @list;

    Cheers,

    Brent

    -- Yeah, I'm a Delt.