|Perl Monk, Perl Meditation|
I am attempting to code a subroutine that allows me to scour through a given directory and all subdirectories. This is going to be a small piece of a much larger project so, even though what I am doing within those subdirectories seems trivial, it will be changed later. Anyways, here is the folder tree I am working in:
-->Copy Of I_Am_$$
-->Copy Of Some$$
-->Copy Of Not_Found
-->Copy2 of I_Am_$$
-->Copy2 of Some$$
-->Copy of Not_Found
Each of the files with the (dir) following it is a subdirectory the (dir) is just a tag posted here, it is not in the actual names of the subdirectories.
I am trying to run Search_Dir.plx to go through this file tree and print to output.txt a list of all of the filenames that contain $$ (again, seems trivial, but this is because I am building up to stuff).
So here is what the contents of Search_Dir.plx look like now:
So when I run the script I tell it to search through the TryMe directory. It seems to find the first two $$ files successfully and print them to output.txt. However, it does not seem to get into the subdirectory logic at all. That is, when I feed it the logic:
...the -d $file sections seems to always return false. At first I thought that the problem came from calling the subroutine from within itself. However, to troubleshoot, I just put a generic print "Here\n"; statement within that same section of the if statement (-d $file) and nothing ever printed. So I guess my final question is, why isn't my subroutine detecting the subdirectories within the file tree. Or, for that matter, why isn't the -d test returning true?
Also, as a disclaimer, I know there is a module that handles this kind of thing called File::Find. However, part of the reason I am trying to code this is just as a learning exercise. Furthermore, I want some customize-ability for where I am going to use this subroutine later. So despite there being an existing module, I would still like to work this out using file and directory handles and the readdir command myself (same goes for grep function).
Let me know if there is anything else anyone needs to assess this problem. I am working on a Windows XP machine with the strawberry perl 5.10 distribution.
Thank you in advance,