The logic of your program is all wrong.

After extracting your filter preferences, you start a first ("outer") loop where you go through the filters one by one.

Inside that loop you read the input file and check the filter condition for each line of the input file ("inner" loop).

BUT when you end the "inner" loop you have exhausted the input file and when you start the next iteration of your "outer" loop, <IN> will return nothing and your "inner" loop gets skipped.

I really doubt that is what you meant to do. Rather you should open the input file inside the outer loop and close it again after the "inner" loop is finished. The next iteration of the "outer" loop will then open the input file again and start reading it afresh and checking your next filter. Of course that is a slow and wasteful way of working: for every filter you walk the input file afresh. It is OK when the files are small, but it quickly will become unwieldly and slow when the files grow.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

In reply to Re: match search string with column header, do some filtering with matched column, print lines/rows that match filter criteria by CountZero
in thread match search string with column header, do some filtering with matched column, print lines/rows that match filter criteria by dkhalfe

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.