in reply to Re: READDIR - Sort by Time?
in thread READDIR - Sort by Time?

There's an interesting failure mode embedded in
sort { $times{$b} cmp $times{$a}; } map { $times{$_} = (stat $_)[9]; $_; }
That you won't notice if all of your files are recent, but will cause odd results if one or more of your files predate 6:46:40pm, September 8, 2001.

See it?

Replies are listed 'Best First'.
Re: Re: Re: READDIR - Sort by Time?
by BrowserUk (Patriarch) on Sep 24, 2002 at 18:31 UTC

    Yes, though the 'clue' threw me for a few seconds. Thank &deity; for Date::Manip::UnixDate( '%s', 'datestring' );


    Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
Re: Re: Re: READDIR - Sort by Time?
by BrowserUk (Patriarch) on Sep 24, 2002 at 19:04 UTC

    Though the breakpoint appears to be somewhat different?

    perl> print UnixDate( '2:46:40am, September 9, 2001.', '%s') 1000000000 perl>

    Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
      Though the breakpoint appears to be somewhat different?

      Oops. It's dependent on timezone, which classifies it as a subspecies of the dread Heisenbug. You get a different result depending on where you test it.