http://qs321.pair.com?node_id=174603


in reply to user input / reg exp's

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