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 File::Find qw(finddepth);
use 5.10.0;
my @files;
finddepth(
sub {
return if ($_ eq '.' || $_ eq '..');
push @files, $File::Find::name;
},
'/my/dir/to/search'
);
say $_ for @files;
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.
Ah thanks for the tip. I wasn’t aware of these.