in reply to Some problems with my code - Help...
Your code has a number of problems:
Anyway, none of this really helps you solve your problem. I would put the directory listings in a separate directory. Take a look at this code (untested):
Good luck with learning Perl. I strongly recommend learning Perl properly--get yourself a copy of "Learning Perl". Your investment in learning Perl will pay back very quickly.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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Some problems with my code - Help...
by BazB (Priest) on May 26, 2003 at 21:46 UTC | |
|
Re: Re: Some problems with my code - Help...
by star7 (Novice) on May 26, 2003 at 22:11 UTC |