On Dec 23, 2003, at 11:52 AM, Johnson, Shaunn wrote: [..]
[..]But how can I get a list of files in a subdirectory without having to specify all of the subdirectories as a variable? (I hope that made sense).
It sounds like I'd have to do something like get a list of subdirectories first and then do a search for .txt files in each subdirectory?
Rob has offered up the classic File::Find solution.
Otherwise what you will want to do is build a tree traverser yourself. You do not actually need to chdir() into the directories - but would need to remember that when you open the dir_block that the 'short names' are not going to be the full path.
cf: <http://www.wetware.com/drieux/pbl/Sys/FS/dir_walk.plx>
Personally I think going with the File::Find is always the better long term solution - unless of course one is trying to learn about how to deal with things like recursion, and how to solve the classic problem of how to check enroute to something else, rather than having to solve
what are the sub_directories I will want to traverse so that I can put them in an array...
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>