To compare any two groups, you'd do something like:
sub is_ok { my ($x, $y) = @_; my (%x, %y); @x{@$x} = 1; @y{@$y} = 1; foreach my $k (keys %x) { return 0 if exists $y{$k}; } return 1; }
Put in a loop, as necessary. Lather, rinse, repeat. A few notes:
  1. This will work with groups of arbitrary size and will also work with groups of different sizes.
  2. It will also work with groups that contain arbitrary data.
  3. It will throw warnings if any of the elements are undef.
  4. It does string comparisons, so 2, 4, 6 and 1.0, 2.0, 3.0 may or may not be ok. I will leave numeric comparisons as an exercise for the reader.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.


In reply to Re: Pair of items by dragonchild
in thread Pair of items by artist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.