in reply to Re: Perl SFTP question?
in thread Perl SFTP question?

I thought about that approach but I rejected it. What exactly could you have the subroutine do? I think if you look at the source code, Net::SFTP will do nothing with the return value of the subroutine so your only option is to write it somewhere else. That is either going to be really bad and ugly or perhaps in some fascinating circumstances really elegant (but hard to understand).

Replies are listed 'Best First'.
Re^3: Perl SFTP question?
by kennethk (Abbot) on Oct 06, 2009 at 21:58 UTC
    I naively assumed that the ls call returned a list of return results from the passed coderef, and having looked at the source I can't help wondering why the module writer didn't do that (the values just get dumped since it explicitly returns an empty array; I really don't understand that choice). I would say then the best choice is using a closure to export the data value. If the OP only wants the oldest value, a simple compare and drop would probably be best. Otherwise, he could use the closure to export an array of the mtime and longname values. He's already caching search results using a closure, so neither of those should be a challenge. Explicitly performing an element-by-element stat seems like excess. I will concede that it gains clarity.