Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

I need to print files by order of the timestamp in a directory on a remote Windows server. I have the code to print files by order of the file names. But I do not know how to change it to print files by order of the timestamp. I am using Net::SFTP::Foreign module. The current code is as below. The "ordered => 1" option is to print by file name. What is the option to print by the timestamp? I really appreciate if anyone can help.

[CODE]
$sftp->ls('Win_Directory', ordered => 1, wanted => sub {
if ( $_[1]->{longname} =~ /^d/ ) {
$dircount++;
} else {
print "$_[1]->{longname} \n";
}
}
)
[/CODE]


I don't think the module

I don't think the module provide what you need, but the 'ls' function from Net::SFTP::Foreign returns a reference to a hash with three keys, one of them is 'long' that returns a string similar to 'ls -l', so I suggest you store that values in an array and then sort the array by time.