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 | |
by thor (Priest) on Sep 09, 2004 at 11:30 UTC |