|Syntactic Confectionery Delight|
Re: Perl SFTP question?by kennethk (Monsignor)
|on Oct 06, 2009 at 21:29 UTC||Need Help??|
You might do well to read How do I post a question effectively? and Writeup Formatting Tips. In particular, you should be wrapping code in <code> tags and try to make sure published code is runnable as written. You are clearly using modules but have not specified what modules you are using.
Based upon your syntax, I am gussing you are using the Net::SFTP module. From the module's documentation:
$sftp->ls($remote [, $subref ])
You can therefore recover the -l result by changing your key from filename to longname. Your sorting options take a little more work, since you need the complete list to sort it. I would suggest you modify your subroutine to return an array ref with the longname and mtime, and then use sort with a custom function on the returned list.
Update: As SilasTheMonk points out below, following this approach requires a closure to cache search results rather than the simple return I describe above.
Update 2: Having reread the above, the return value from an ordinary call to $sftp->ls contains all the information you need to recover your desired result (untested).
If the above fails, you need to look at the format of the mtime return to fix the compare.