Here is a fairly simple one I used recently. In my case I used finddepth (searches from the bottom up instead of top down) because I was renaming folders and File::Find couldn't chdir to the folder after I had changed the name. find() works the same way.
In the example below, finddepth runs my subroutine BadNames on every file below c:\Directory. ########################################################### use strict; use warnings; use File::Find; $| = 1; #Autoflush STDOUT #finddepth comes from File::Find #finddepth searches from the bottom of the tree up finddepth(\&BadNames,"c:\\Directory"); sub BadNames{ #NOTE: finddepth chdirs to the directory it's # traversing and sets the filename to $_. # $File::Find::name is the full path to the file #if it contains a &,#, or ends with .com if($_ =~ /(\&|\#|\.com$)/){ print "Converting ".$File::Find::name."..."; my $filename = $_; $filename =~ s/\&/and/g; $filename =~ s/\#/_/g; $filename =~ s/\.com$/\.com_/i; #Rename the file rename($_,$filename) or die "Couldn't rename $_!"; print "done\n"; } } ########################################################### -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 01, 2005 12:39 PM To: beginners@perl.org Subject: File::Find implementation Hello: I got some advice on how to obtain a listing of all the files on a hard drive. The advice was to use File::find. I looked at the perl document and I am a little confused and so a simple example would be nice. I would like to get the file name, directory path, size and date of last modification. This is being run on a pc. How can I get this information into an array? How would the file entry look. I know I will need a @file_list = find(param list where c:\ would be the top level directoru); Thanks, Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>