On 2/22/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
Hello All, I need to search a particular string in a set of files in a directory. The string appears only in one of the files in the directory. I need to retrieve the file name and then access the line of that particular file in which the string occurs. NOTE: The perl script also resides in the same directory. For Eg: I am in search of string $string = "PERL_BEGINNER"; i have a directory => /Users/ and the files in that directory are: 1. Beginners.h 2. Learners.h 3. Experts.h 4. etc.... Among these files $string occurs only in one of the files. If we assume that it occurs in "Beginners.h" then Beginners.h has to be opened and the $string has to be searched in that file. Can i know how i can go about this in Perl? What functions i might have to use? I kindly request to guide me in this. Thanks and Regards, Dharshana
I forgot to mention, First step is to Search for the file in which the string occurs Second step is to Open the file in which the string is present Third Step is to Get the file pointer to the line in which the string occurs. NOTE: I might have to use the code both in Unix and Windows platform. I dont have a problem if i have two different solutions for each of the platforms or if one solution for both the platforms. I kindly request to guide me in this. Thanks and Regards, Dharshana