Welcome to the Monastery | |
PerlMonks |
Re: Recursive Subdirectoriesby t'mo (Pilgrim) |
on Apr 18, 2003 at 05:26 UTC ( [id://251388]=note: print w/replies, xml ) | Need Help?? |
Two ideas. 1) In the spirit of TMTOWTDI ("there's more than one way to do it"), and since you're running this on Windows, why not borrow some COM objects, or more specifically, the "Scripting.FileSystemObject". 2), Really, this probelm is nothing more than a depth-first traversal of a tree; File::Find just does the traversal for you. The beauty of combining these two ideas is that you still can see what your program does (i.e., the recursive nature of the problem and solution is hidden in File::Find), but because the FileSystemObject has methods giving you either the files or the directories: you don't have to check to see whether you have a file or a directory from readdir. The following is not unlike a WSH program I recently had to hack together...except that the Perl hasn't been tested, since (in theory) I work in a Microsoft-only shop...:
p.s. Thanks to this reference, which indirectly pointed out that I should use Win32::OLE 'in'; I was able to actually make this thing *almost* work. ...every application I have ever worked on is a glorified munger...
In Section
Seekers of Perl Wisdom
|
|