Hi All,
I have a remote directory wherein some files will be generated. I am writting a PERL script in windows to get the latest file created in that directory.How do i achieve this?
This is what i have tried so far...
looks like opendir gives random file list. Its not in a sorted order. How do i sort files in a directory based on the file modification time?
Thanks in advance.
Regards
Pramod
I have a remote directory wherein some files will be generated. I am writting a PERL script in windows to get the latest file created in that directory.How do i achieve this?
This is what i have tried so far...
Code:
use FindBin;
use strict;
my $ScriptPath = $FindBin::Bin;
print "\n Script Path = $ScriptPath ";
my @files = "";
### remote directory
my $dirPath = "D:\\Test\\TestMaintenance";
opendir(DIRHANDLE, "$dirPath") or return("\n Can not open $dirPath \n $!");
while ( defined (my $filename = readdir(DIRHANDLE)) ){
if($filename =~ m/TestMaintenance/){
print "\n$filename";
push(@files, $filename);
}
}
close DIRHANDLE;
Thanks in advance.
Regards
Pramod
Comment