From the description you gave this psuedo code may match the problem (yeah, I'm being hesitant)
if ( file1-field2 eq file2-field5 ) {
give me file2-field_to_be_named || first_round_draft_pick
}
OK, kidding about the draft pick.
If this is close to the truth, consider these fragments to work with:
my %file1;
my %file2;
while(<file1>) {
my $field_from_1 = (split /<DELIMiTER>/)[1];
$file1{$field_from_1}++;
}
while(<file2>) {
my ($field_from_2, $record_we_want) = (split /<DELIMITER>/)[4,index
+_we_cant_guess_from_description];
$file2{$field_from_2} = $record_we_want;
}
foreach my $keys ( %file2 ) {
if ( exists $file1{$key} ) {
# do whatever it is they want with $record_we_want
}
}
Those snips require a reasonably small subset of the memory needed to do what you described. Perhaps small enough to do the entire task in memory. What they don't do is:
- Preserve the order of the records, but we don't know if that's important from your description
- Preserve duplicate ID records, but we don't ...
If this is not helpful I'll join the first two responders in requesting you provide more information. A few lines of sanatized data file and a sample of the code you've developed so far will do wonders for our helpfulness.
Update: destressed some tortured English
Be Appropriate && Follow Your Curiosity
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.