I am a beginner here, but the program I am working on was done by a "pro". It works fine the way it weas set up, but it need updating, and he is no longer around, so it is up to me. The purpose of the program is to take user input and search in the online file and return matching records. It uses many different fields, and if a user enters more than one word, it treats the two words as one, and only returns when the pair are found together. I wanted to change this so it would find any combination of the two words. My first step was to create an array of all the words. This worked. Then I created a loop on the search function, and it kinda worked. I will post the segment here, with my comments. :
if($lT && $Title ne "*") { for($index=0;$index<@tit;$index++) { $wrd=$tit[$index]; print "$index,$wrd\n"; COMMENT - to make sure each word was processed +individually. Works. `grep -i \"$wrd\" $DataIn > $DataTmp`; COMMENT - I am assuming that th +e GREP results from DataIn are copied into DataTmp $DataIn=$DataTmp; COMMENT - here the files are swapped I guess. if($DataTmp eq $DataTmpa){$DataTmp=$DataTmpb;print "tempb\n";} # if else{$DataTmp=$DataTmpa;print "tempa\n";} # else } # for } # if $IT
Logically I would think that this should work. Take the words "WE LOVE", the first pass thru should take all the lines that contain the word "WE" and place them into DataTmp, which is then assigned back to DataIn. The second pass should then take all the lines that contain "LOVE" and place that in DataTmp, etc. However, the final output only shows those lines that have "WE LOVE" in them in that order, which is exactly what it did before my changes. is there something simple I am overlooking, or?? Thank you, Glenn

In reply to Online GREP problem by gfausel

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.