I want to traverse a durectory for a particular file. Situataion is like this. Path is ABC/a/c/g. it has around 100 folders in it.
Search a directory which has word "*latest*" in its path.
and then from the latest go through z/x/c to file final.html.
In total, i want it to go through ABC/a/c/g/*latest*/z/x/c/final.html. This way I want my perl script to search for all the 6 out of the 100 final.html files.
I also want the whole path printed after it finds the final.html files.
I'm not sure I follow your question but you can use the above to to read through directories and thus select your file.
something like the following may suit or at least be hackable into something that suits
my $base='ABC/a/c/g';
my $tail='z/x/c';
opendir BASE, $base;
my @subdirs = readir BASE;
for my $dir (@subdirs){
if (($dir=~/latest/) && ( -d "$base/$dir")){
if ( -f "$base/$dir/$tail/final.html"){
print "$base/$dir/$tail/final.html";
}
}
}
Of course I may have wildly misunderstood your spec and something like File::Find may be more suitable for your needs.
Thanks for the help.
but if latest was only a part of my string what should i do.
i mean i have folder like
'ABC/a/c/g(base) /123_latest_6678090765abcww12/ Tail?
I am am trying to learn perl and thinking of what all i can handle with various scenarios.