in reply to Managing multiple keys in a hash table...
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!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", $/; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Managing multiple keys in a hash table...
by ikegami (Patriarch) on Jun 02, 2005 at 18:02 UTC |