in reply to Get Filename using perl

What do you want to happen if there is more than one file with the keyword? The (non-perl) grep utility is the usual way to solve this problem.

Guessing that you don't have system grep, you should generate a list of all filenames of interest with glob. Then open each and loop through the contents trying to match the keyword with the match operator, m/APPLES/. If a match is found, note the filename and go on to the next. That can be done in a way that generates an array of qualified files, using push.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Get Filename using perl
by Anonymous Monk on Sep 09, 2004 at 01:34 UTC
    I know for a fact that there will be only one UNIQUE KEYWORD, which will not be repeated in any other file
      As they say, assumption is the mother of all foul-ups. The computer does exactly what it's told. At some point, someone will tell it to place the keyword in more than one file. At that point, things will break if you haven't decided to deal with it gracefully.

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come