in reply to Is one array a subset of the other
As soon as you're thinking of "sets" of unique items and not particularly interested in their order, use hashes.
Untested.
my %a1; @a1{qw(a b c d e f g)} = (); my %a2; @a2{qw(b g)} = (); my @a1only = grep { not exists $a2{$_} } keys %a1; my @a2only = grep { not exists $a1{$_} } keys %a2; my @both = grep { exists $a2{$_} } keys %a1; my %u; my @either = grep { not $u{$_}++ } (keys %a1, keys %a2); # your question: print "subset" if not @a2only;
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Is one array a subset of the other
by pzbagel (Chaplain) on May 19, 2003 at 20:10 UTC | |
by halley (Prior) on May 19, 2003 at 20:15 UTC |