goosefairy has asked for the wisdom of the Perl Monks concerning the following question:
I need to search for a specific piece of text in all files in a directory. Since I also need to do this recursively I want to use File::Find.
I can return file names easily. What I need to do, though, is to search for the pattern then only print out those files which have the pattern in it. I don't want to do anything to the files; I just want a list returned.
I know it's simple but for some reason I have thrown up a brick wall.
I'm assuming (I know that can be dangerous) that I would need to do an open(FH, $file) on each file returned then search for the pattern then.
Am I even on the right track?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: text search in a file
by shemp (Deacon) on Aug 10, 2005 at 21:55 UTC | |
by davidrw (Prior) on Aug 10, 2005 at 22:18 UTC | |
by kwaping (Priest) on Aug 10, 2005 at 22:22 UTC | |
by Tanktalus (Canon) on Aug 11, 2005 at 01:55 UTC | |
by graff (Chancellor) on Aug 11, 2005 at 11:35 UTC | |
by davis (Vicar) on Aug 11, 2005 at 09:28 UTC | |
by gellyfish (Monsignor) on Aug 11, 2005 at 09:34 UTC | |
by kwaping (Priest) on Aug 11, 2005 at 15:41 UTC | |
by Fletch (Bishop) on Aug 11, 2005 at 02:52 UTC | |
by goosefairy (Novice) on Aug 10, 2005 at 22:07 UTC | |
|
Re: text search in a file
by sgifford (Prior) on Aug 10, 2005 at 22:23 UTC | |
|
Re: text search in a file
by gellyfish (Monsignor) on Aug 10, 2005 at 21:53 UTC |