I also found this quite difficult to understand. I assumed your lists were arrays and that your keys were stored in hashes. Following those assumptions i producted this:
my @list1 = qw/a b c d e f g/; my @list2 = qw/a b c d e /; my %one = ( a => 1, b => 1, c => 1 ); my %two = ( f => 1, g => 1 ); for my $key ( keys %one ) { if ( grep {$_ eq $key} @list1 and grep {$_ eq $key} @list2) { print +"File 1 $key", $/ } } for my $key ( keys %two ) { unless ( grep {$_ eq $key} @list1 and grep {$_ eq $key} @list2 ) { if ( grep {$_ eq $key} @list1 or grep {$_ eq $key} @list2 ) { print "File 2 $key", $/; } } }
This will work for: "If key1 is matched between list1 and list2 write to a file. Then, after the key1 match is made, check if key2 is NOT matched between list1 and list2 then write to another file" Although it is hard to follow what exactly you have set up, or i could provide a more thorough answer. Hope this helps a little bit!

In reply to Re: Managing multiple keys in a hash table... by mayhem
in thread Managing multiple keys in a hash table... by Anonymous Monk

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.