in reply to Text Files Matching Items
If I understand your question, you have lines of data being read from two distinct inputs, and some of these lines are expected to contain values that are common to both inputs. Looking at the code and comments you've posted, there's not much else that can be known for sure.
Happy-the-monk's reply probably points to the best approach. Read all the lines from one input first, storing the presumed common strings as keys in a hash. If you need the whole line (or some other portion of the line) later on when reporting matches, save that as the value of the hash for the given key.
After you've read all of the first input, start reading the second one; for each input line, isolate the string (if any) that should match the first file and see if a hash element exists with that string as the hash key (see "perldoc -f exists"). If so, you now have the full current line from the second input file, and you have whatever portion of the matching line you needed from the first file (if any). Print the match, and continue reading from the second file.
|
|---|