drieux wrote: > 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
Thanks. I agree on both points. Given the tested and proven nature of standard modules, it is definitely more responsible to use them in production work. OTOH, the too-quick recourse to packaged functionality can short-circuit the development of skills, and more importantly, conceptual mastery, for the student. I see recursion as an essential concept for developing programmers to grasp and integrate, and a directory tree is probably the most available practical example of its application. Whatever is finally used in production code, the exercise of writing a directory tree traversal is worthwhile in itself. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>