Another way to recurse a directory and print the files you want to get,the following is the code.
use strict;
use warnings;
sub ransack
{
#dir,\@files
my $dir=shift;
my $files=shift;
my @array=glob("$dir\\*");
foreach my $item (@array) {
if(-d $item) {
ransack($item,$files);
}
else {
$files->[@$files]=$item;
}
}
}
my ($array, @array);
ransack("path of your directory",\@array); #path of your directory
foreach $array (@array)
{
if ($array=~/txt|csv/) { #match your file format
print ("$array\n");
}
}
Enjoy!