Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Help regarding an alogrithm

by samarzone (Pilgrim)
on Mar 18, 2011 at 06:13 UTC ( #893913=note: print w/ replies, xml ) Need Help??


in reply to Help regarding an alogrithm

  1. Read file "data.txt" line by line. Every line has name of a directory.
  2. Find all the *.c files in current directory and run a loop on these files
  3. Inside above loop read every line of current (*.c) file and run a regular expression to match "modem" case-insensitively with word boundary.
  4. If any of the match (in case of multiple matches) is not equal to (eq) "modem" print the line and file (*.c) name

I hope this helps

--
Regards
- Samar


Comment on Re: Help regarding an alogrithm
Download Code
Replies are listed 'Best First'.
Re^2: Help regarding an alogrithm
by perl_mystery (Beadle) on Mar 18, 2011 at 06:24 UTC

    At step #3,for every file I open,I need to search for all the contents present in data.txt ,not only modem,basically for every .c I have to check if any of the dir names in data.txt are present,how do I match that ?am already in a for loop opening each and every .c files

      Read the contents of "data.txt" in an array and run a loop on the array as step#1. This way you have all the directory names with you in the array, at the step #3. Run step #3 and #4 for all the names in array instead of just "modem"

      --
      Regards
      - Samar

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://893913]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (17)
As of 2015-07-31 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls