Welcome to the Monastery, harishnv. I can't tell if your post was always empty or if you've removed its contents, but either way, please see How do I post a question effectively? for some guidelines on how to best ask questions. Normally, it'd be good if you include the code you have tried, how you expect it to behave, what is going wrong with it including exact error messages, and any other information so that we can reproduce the situation on our end, for example sample input and the expected output for that input. A question consisting of just the title is normally not enough information to go on. Please see How do I change/delete my post? for how to edit your node to include more information.
hey how to recursively access the directroies to search for a keyword and print its file name and the keyword line?
For recursively finding files, you could use the core module File::Find, or with a nicer interface File::Find::Rule. Then, for each file, you could open it, read it line-by-line, use a regular expression to find matches, and get the current line number from the special variable $.. Everything you need for that is explained in perlintro, pay particular attention to the description of foreach (for looping over a list of files) and the sections "Files and I/O" and "Regular expressions".
| [reply] [d/l] [select] |
hello harishnv and welcome to the monastery and to the wonderful world of perl!
more effort you show from your part, more help you, possibly, get back. This gold rule will be very useful for your time here.
In addition Super Search is you friend but be sure to search directories and not directroies
Hint: this is the oldest questione posed in the monastery.. you can also spot some clue about this question in my homenode
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] [select] |
$ grep -rn keyword root_dir/*
The way forward always starts with a minimal test.
| [reply] [d/l] |
| [reply] |
i got the answer using grep function.
thanks for the support
| [reply] |