in reply to Assesing file timestamp

my $latest = (sort { -M $a <=> -M $b } </path/to/dir/*.log>)[0];
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Assesing file timestamp
by Hofmator (Curate) on Jan 30, 2003 at 14:06 UTC
    Isn't that horribly inefficient to stat a file multiple times in the sort? Wouldn't this be the perfect place for a Schwartzian transform (as employed by broquaint) or an 'orcish' maneuver?

    Or am I missing some internal caching going on here?

    Update: Got a bit carried away there with my adverb ... I just wanted to make sure that I hadn't missed anything. Thanks for the clarification, davorg.

    -- Hofmator

      Well, I don't know about "horribly inefficient", but it's certainly not the fastest way to do it. broquaint's solution would be faster.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg