"Stephen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm doing my best but having a lot of trouble understanding the > documentation for File::Find. After seeing a number of people being > yelled at for trying to reinvent the wheel by writing their own > functions, I'm resigned to throwing up my hands and begging for someone > to hold my hand through a concrete example, hopefully showing how the > pre\post\process functions are invoked and can be used. > > Also, I'm wondering if there's a way to implement a mechanism that times > the execution of the script. > > ________________________ > > # Recurse a defined directory summarising folder information based on > # file type and then provide a way to call other functions to perform > # actions on any of those files. > > use strict; > use warnings; > use File::Find; > > find(\&wanted, "C:/SomeFolder"); > > sub wanted { > my $dir_count = 0; > if (-d $_) { > print "."; > $dir_count++; > > # rest of code that finishes with print statements something like: > # "There are $file_total files in $dir_count directories." > # "The folder \"($folder_name)\" contains $files_in_folder .TXT files."
Hi Stephen. Yes, the File::Find documentation is awful. But I shan't complain as I haven't offered to update it either. This sounds like a tutorial question? I'm not sure about the second part of your problem but the code below solves the first. See what you think. Rob use strict; use warnings; use File::Find; my $file_count = 0; my $dir_count = 0; find (\&wanted, "C:/SomeFolder"); sub wanted { if (-d) { return unless /[^.]/; $dir_count++; } elsif (-f _) { $file_count++; } } printf "There are %d files in %d directories.\n", $file_count, $dir_count; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]