I am not sure if I understood your requirement completely. You can make use of File::Find module to recursively search inside a directory.
If you want to search all .lst files inside all year directories, for a particular file in the list ($ExtractFile) and get the list of target zip files, you can make use of this piece of code.
-
use File::Find;
-
#
-
#
-
#
-
#
-
my @targets;
-
-
find(
-
sub {
-
my $file =$File::Find::name;#contains entire path of file
-
if((-f $file) && $file=~/\.lst/) {
-
open(F,"$file") or die "error:$!";
-
my @file= <F>;
-
if(grep /$ExtractFile/,@file){
-
my $reqyear = $1 if($file=~/\/(\d{4})\/.+?$/);##get the year
-
$file=~s/\.lst/\.tar\.gz/; # get the target zip file
-
push @targets,$file; # get the list of targets
-
}
-
} },
-
$ArchiveDIR); ## recursively search in $ArchiveDIR
-
-