Welcome to the Monastery | |
PerlMonks |
Comparing multiple entries from two filesby hanger4 (Initiate) |
on Jul 07, 2009 at 23:06 UTC ( [id://778065]=perlquestion: print w/replies, xml ) | Need Help?? |
hanger4 has asked for the wisdom of the Perl Monks concerning the following question:
Hello all,
I've been working on a project for the past week or so and have gotten stumped on this step. It's easier to explain with an example so here it is...
There are two input files, an ID file of 3 columns and a Name file of four columns (the actual data are large ~ 100,000 rows):
ID file:
Name file: For each row in the ID file, I need to compare the Catg_ID variable to the Catg_Name variable in the Name file. Then, if the catg variables match, I want to see if Pos is between Start and Stop. For rows that meet both the above criteria, I want to combine them in a single output file. So, to recap, IF Catg_ID = Catg_Name AND Pos > Start AND Pos < Stop I want to print "ID Catg_ID Pos Name" And just to be clear, I need to compare not the first line in the ID file to the first line in the name file, but the first line in the ID file to every line in the name file, then the second line in the ID file to every line in the name file, and so on. Multiple matches are fine.
For the above data, I would want the program to print: Thanks in advance. I've tried to be as clear and specific as possible.
Back to
Seekers of Perl Wisdom
|
|