Use File::Find for recursive directory searches
One of the finest Perl (core!) module I’ve been using lately is File::Find. With File::Find it’s possible to traverse through a directory recursively to find anything you want from it. It comes with a number of options to alter the search behavior and a custom callback has to be supplied to determine what to do with the found file. Such as adding it to a list if it meets certain criteria, computing MD5 checksums or whatever else floats your boat.
Here’s a small example I also posted some time ago on Stack Overflow.
-
use strict;
-
use warnings;
-
use 5.10.0;
-
-
my @files;
-
finddepth(
-
sub {
-
},
-
‘/my/dir/to/search’
-
);
-
-
say $_ for @files;
You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.


Just in case that you wanted to try something else I would recommend that you tried some of the other File::Find::* modules at CPAN.
Htbaa Reply:
August 22nd, 2010 at 10:08
Ah thanks for the tip. I wasn’t aware of these.