On Friday, November 28, 2003, at 08:51 PM, drieux wrote:
a. how did you initialize it to begin with and why not simple re-use that solution
The hash consists of filenames, line numbers and strings.
$HASH{$file}{$line} = line of code from some file.
So the script goes along scouring the present directory for all instances of files of type '*.foo' and when it comes to one, it searches every last line of it for the pattern /\bfoo\b/ and if (and only if) there is a foo in the file, the it puts the name of the file in the hash, and then puts the number of each line containing /\bfoo\b/ in the hash under the file's name, and then puts the line of code containing /\bfoo\b/ under the line number. Then it prints out the hash and tells me what directory it was in when it did all this.
So this is all fine well and good. But let us say that I wish to rewrite the script so that it scours many directories in sequence, and then tells me what it did in each one. There is only one thing that needs to be changed - each time it comes to a new directory, it should wipe the hash. Then each directories report will not be contaminated by the previous report. If I were to simply use the way I had initialized the hash in the first place, I would get a very long report for the last directory, most of which would be about files in other directories! So I need to nuke the hash each time I go through the loop.
- Jason
When Banzan was walking through the Union Square greenmarket he overheard a conversation between a vendor and his customer. "Do you have chocolate mousse?" asked the customer. "We have chocolate pudding," replied the vendor. At these words Banzan became enlightened. -Mike Topp