Rob Dixon wrote: > > I think somebody mentioned it before, but what you need is File::Find. > This code > will put into @new the names of all the files in and below $path. > > use strict; > use warnings; > > use File::Find; > > my @new; > > find(sub {push @new, $File::Find::name}, $path); > > print "$_\n" foreach @new; > > Now beware that all files and directories are included. I've never been sure > whether you were interested in the directory names, and if you want to filter > out the directories and leave just the files, change the call to find() like > this: > > find(sub {push @new, $File::Find::name if -f}, $path); > > This solution has the advantage that File::Find doesn't return the pseudo- > directories '.' and '..' so we have nothing to worry about on that score :)
I just looked at your original post again, and it may well be that you're not interested in the directory path to the file at all, in which case change the line again to: find(sub {push @new, $_ if -f}, $path); which will leave just the bare filenames in the array. Remember to take off the 'if -f' if you want directories in the list too. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>