use strict; use warnings; use File::Find; my $listings_dir = 'c:/listings'; find(\&callback, 'c:/tmp'); sub callback { my $file = $_; # Check to see if $file is a directory if (-d $file) { # Get a list of all the files in the directory (inefficient) # (If you only want the filenames rather than paths as well, # investigate using File::Basename. If you want just the files # in a directory, and directories within the directory, # consider putting grep { -f $_ } before the glob. my (@files) = glob($File::Find::dir . "/$_/*"); # Save this list to a file open LISTING, ">$listings_dir/list$_.txt"; print LISTING join ("\n", @files); close LISTING; } }