Note that my code uses File::Find::Rule which has a very user friendly interface (as opposed to File::Find). I am not sure what was difficult to understand from my example but it does exactly what you asked for.
I will comment on a few snippets of your code.
opendir DH, $dir_to_process # Use a lexical ($dir) instead of a bareword global (DH) if possible
if ($file =~ /\.txt$/) # This would break for a directory called dir.txt - see perldoc -f -X
%stuff_to_store = ($dir_to_process, $file); # This overwrites the hash entirely every time
while (%stuff_to_store) { # this will be an infinite loop if the hash contains any items
Please note: Your code will only search the current directory - it will not descend into sub directories. Out of curiosity, how much time did you spend with the code I wrote before you gave up on it? It really does 97% of what you asked.
Cheers - L~R
In reply to Re^3: Search and store solution?
by Limbic~Region
in thread Search and store solution?
by nukeboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |