You could use a single hash, using the Ob2 value as key, and a counter as the value. Keys that end up with a value of 1 are unique to a single Ob1, while keys with a value greater than 1 are common to both.
Here's some code:
#!/usr/bin/perl
my %ob2;
while( <DATA> ) {
my @v = split;
$ob2{ $v[3] } ++;
}
print "Duplicate Ob2: ",
join ', ',
sort grep { $ob2{ $_ } > 1 } keys %ob2;
__DATA__
HIT object1 563.43.78 object3 123.89.7777
HIT object1 563.43.78 object10 123.89.7777
HIT object1 563.43.78 object2 453.78.122
HIT object1 563.43.78 object5 457.8888.1
HIT object1 563.43.78 object4 123.89.7777
HIT object1 563.43.78 object6 566.2222.11
HIT object2 563.43.78 object3 123.89.7777
HIT object2 563.43.78 object7 456.222.1111
HIT object2 563.43.78 object8 990.7777.66
HIT object2 563.43.78 object5 457.8888.1
HIT object2 563.43.78 object13 123.89.7777
HIT object2 563.43.78 object9 1223.333.111
That prints:
Duplicate Ob2: object3, object5
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.