Running Perl on WinXP I would like to read the subdirectories and their respective files, that I have on my F: drive. They are arranged hierarchically, with a directory for each year, each of which contains a directory for each month, each of which contains files named for days. Like this:
F: 2005 Jan2005 01-01-2005.txt 01-03-2005.txt Feb2005 02-01-2005.txt and so on. F: contains four directories: 2005, 2006, 2007 and Students There are also a few odd files stored directly in F: I am not interested in reading those, or doing anything with them. The problem is, they too get read and listed by my code. Here's what I have so far: -------------------------------------------------------------- my $line; # this is for use later, to read the contents of each file my $herenow; # my @linelist # also for use later use Cwd; chdir 'F:/DICTATIONS' or die "$!"; $herenow = getcwd; # check to see "where I am." print $herenow; opendir TOTALHANDLE, "." or die "Couldn't open the specified directory: $!"; while ($yearly = readdir(TOTALHANDLE)) { print "$yearly \n"; opendir YH, "F:/DICTATIONS/$yearly" or die "Couldn't open the specified directory: $!"; while ($monthly = readdir(YH)) { print "$monthly \n"; } } ------------------------------------------------------------------- And here's the output of the above code [my comments are in square brackets]: C:\DATA\computer stuff\PerlStuff>perl -w ExtractPatients2.pl F:/DICTATIONS. . .. Students 2005 2006 2007 .. [the assortment of odd files listed here] NonTextDictations [a directory inside F:] Students . .. [list of files inside F:\DICTATIONS\Students] 2005 . .. January2005 February2005 March2005 April2005 May2005 June2005 July2005 August2005 September2005 October2005 November2005 December2005 2006 . .. January2006 February2006 March2006 April2006 May2006 June2006 July2006 August2006 September2006 October2006 November2006 December2006 2007 . .. January2007 February2007 March2007 April2007 May2007 June2007 C:\DATA\computer stuff\PerlStuff> I want to list only the monthly subdirectories inside each yearly subdirectory inside the directory DICTATIONS on F:. I don't want the assorted "loose" files that are stored directly on F:, outside of a subdirectory. And I can't understand why they are getting listed here, if my working directory is set properly to F:\DICTATIONS (which I think it is) and not to F:\ Appreciate any advice. Thanks. --Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/