Here is a sample to get a list of files recursively from a folder.
use strict;
use File::Find;
use File::Copy;
use Data::Dumper;
my @FILE_LIST;
# -- main --
{
my $sDir = "/home/username";
my @aFileList = GetFileList($sDir);
}
# ----------------------------
sub GetFileList($)
# ----------------------------
{
my $root = shift;
@FILE_LIST = ();
find(\&filter, $root);
return @FILE_LIST;
}
# ----------------------------
sub filter
# ----------------------------
{
my $root = $File::Find::topdir;
my $path = $File::Find::name;
my $file_name = $_;
if( $file_name =~ /\.(cgi|pl)$/i )
{
$root =~ s/\\/\\\\/g;
$path =~ s/^$root[\/\\]//;
push @FILE_LIST, $path;
}
}