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 "; } } }

In reply to Threading two text files by ostra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.