in reply to What's the difference between stat and sort?

If you want the lexically last file in the directory, you don't need to sort as glob sorts it output anyway--least on my system it does.

perl -le"print +(<*>)[-1]" XXX_I386

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^2: What's the difference between stat and sort?
by beable (Friar) on Jul 15, 2004 at 10:35 UTC
    "At least on my system"? Oh now that's not good enough! perldoc -f glob says: "Beginning with v5.6.0, this operator is implemented using the standard "File::Glob" extension. See File::Glob for details."

    perldoc File::Glob says: ""GLOB_NOSORT" By default, the pathnames are sorted in ascending ASCII order; this flag prevents that sorting (speeding up bsd_glob())."

    So there we go, a definitive answer for Perls greater than 5.6.0. As for previous Perls, upgrade already!

      I didn't need to look it up. I already knew it sorted on my system :)

      Upgrade?


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon