in reply to GREP ISSUE

You are iterating through all of your text files for each rtf file and outputting something for each of them. If I'm reading your question right (and it's not very well asked, imho) it seems like what you want to do is accumulate your results first and then output something. Instead of (pseudocode):

for my $textfile (@textfiles) { if (grep) { output_this_result; } else { output_that_result; } }
You want something like (more pseudocode):
for my $textfile (@textfiles) { if (grep) { push @results, $textfile; } } do_something_with(@results);
And if @results is empty, then that's when you'll record "No Text Files".

Note though that it probably doesn't make sense to open and read each text file once for each filename you are looking for. Just read each text file once and check for all of your filenames at the same time.

Also, you probably want to use quotemeta on your filename before using it as a pattern and maybe add some boundary checking. A filename like foo.rtf would match fooXrtf and bigfoo.rtf or foo.rtf.old. Maybe it doesn't matter for your needs, but you should be aware of it.

-sauoq
"My two cents aren't worth a dime.";