in reply to Re: How can I access a cross directory set of data files by most recently modified date?
in thread How can I access a cross directory set of data files by most recently modified date?

I thought of that, but it seems kind of brute force for something someone probably has solved more elegantly.

  • Comment on Re^2: How can I access a cross directory set of data files by most recently modified date?

Replies are listed 'Best First'.
Re^3: How can I access a cross directory set of data files by most recently modified date?
by Fletch (Bishop) on Jun 07, 2007 at 17:02 UTC

    You can use a schwartzian transform to make it more efficient by only doing the stat call once per file, but other than that there's not that much more to it.

    Update: For those playing along at home that'd be @files = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, (stat $_)[9] ] } @files;

Re^3: How can I access a cross directory set of data files by most recently modified date?
by moritz (Cardinal) on Jun 07, 2007 at 17:00 UTC
    Well, using a binary heap as a data structure might be more efficient, especially if you know you know that you need only the the knewest $k files, then all insertion and deletion operations will be in O(log $k) operations.

    But if you are talking about a more elegant interface: I don't know any :(

      Thanks, that may be the way I need to go, but I would rather not reinvent the square wheel if I don't have to.

      Skip