in reply to problem printing message if search item is not found

You're comparing against $_ outside of the scope of the for loop, thus your regexp will always fail (unless $_ happens to be something that contains your search string).

One way to do this is to have a "found" boolean. Set it to 0 (false) at the beginning of the program, then set it to true only if you find your string.

After your for loop, check for the truth value of the 'found' variable and print your "not found" statement at that time.
  • Comment on Re: problem printing message if search item is not found