ostra has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
My objective is to search a database that is in a text file called qqq.txt with values on another text file called exp.txt. When running this script it only returns one match. If there is a match it should print the text that is associated with the value that is split from the database. I expected 3 matches because the database contains 3 values and the exp.txt file has the same 3 identical values. Its as if the script stops after one iteration. Any suggestions as to how to improve code to resolve this issue would be greatly appreciated. Thank you. And I do realize I did not have "or die" text in Open file statement. Ostra
open(INDB, "exp.txt"); open(DATA, "qqq.txt"); while(<INDB>) { $search = $_; chomp($search); seek(INDB, 0, 0); while(<DATA>) { $therec = $_; chomp($therec); ($ma,$id ) = split(/\t/, $therec); if($id eq $search){ print " $ma\n "; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Threading two text files
by LanX (Saint) on May 14, 2013 at 22:40 UTC | |
by LanX (Saint) on May 15, 2013 at 10:43 UTC | |
by ostra (Novice) on May 15, 2013 at 17:51 UTC | |
by LanX (Saint) on May 15, 2013 at 22:02 UTC | |
|
Re: Threading two text files
by ww (Archbishop) on May 14, 2013 at 23:33 UTC | |
|
Re: Threading two text files
by kcott (Archbishop) on May 15, 2013 at 03:09 UTC | |
|
Re: Threading two text files
by NetWallah (Canon) on May 14, 2013 at 22:02 UTC | |
|
Re: Threading two text files
by Laurent_R (Canon) on May 14, 2013 at 22:44 UTC |