You should only have to read each file once. From the way your describe your algorithm, you want to find things in one file but are not in another. The basic idea is this:
my %seen;
open(B, "brd_sym_pn.txt") or die "...";
while (<B>) {
my ($RefDes, $Pnumm, $Pkg_Type) = ...parse these from the line...
$seen{$RefDes, $Pnumm, $Pkg_Type} = 1;
}
close(B);
open(S, "sym_text_latest.txt") or die "...";
while (<S>) {
my ($RefDes, $Pnumm, $Pkg_Type) = ...parse these from the line...
$seen{$Refdes, $Pnumm, $Pkg_Type} += 2;
}
close(S);
while (my ($key, $val) = each %seen) {
if ($val == 1) {
# $key is in first file but not second
} elsif ($val == 2) {
# $key is in second file but not first
} else {
# key is in both files
}
}
For info on how to interpret
$key, have a look at the documentation for the
$; variable in
perldoc perlvar. For special cases you can optimize this code.
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.