Hi! You are open'ing the input handle FH on you first argument. So far so good.
Inside your main event loop (the do {} while stuff) you read in the complete file with:
while (<FH>) { ... }

Obviously the second time round (when the user is presented the main menu again) the <FH> is going to fail instantly because the read pointer is at the end of the file from the previous reads. Otherwise you wouldn't have returned from the while loop.
If the file isn't too large, I would recommend to first (outside the menu loop) read in the whole file (in an array perhaps) and to do you matching on that, rather than reading the file while you match. Another solution would be to seek (perldoc seek) to the beginning of the file each time you get a choice from the user, but that would be lossage (You don't want to read in the file each time you want to read it, do you ;-)?)

As to your regex problems:
It generally is a bit hard to help improving a regex if one doesn't know the input data.
Thus, if you have a decent short example of input data, I'm sure we can work out a solution.


Hope that helps,
Kay

In reply to Re: user input / reg exp's by janx
in thread user input / reg exp's by Anonymous Monk

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.