in reply to How to list files in dir with respect to time ?

I personally do not like to use the UNIX native commands in script.
That's a pity, since it means you can solve your problem in a single line - and you don't have to ask for a solution. It's also non-Perl, after all, Perl is a glue language.

The roll it your own solution involves using opendir, readdir, stat, sort and printf. You also need getpwnam and getgrnam if you want to similate the -l option of ls, and perhaps grep to filter out dot-files, although that can be done with other means as well. I hope that's enough answer for you, and you can work out the details - I won't bother with them, if

system "ls -lrt";
works just as well.

UNIX Monk

Replies are listed 'Best First'.
Re^2: How to list files in dir with respect to time ?
by fraterm (Scribe) on Aug 16, 2005 at 14:33 UTC

    Well, since Perl doesn't always run on Unix, and that having this dislike is a sign that this activity is likely more than just based on a purely aesthetic concern for the programmer (I guess that they want something that is capable of working interoperably on both win32 and Unixish perl, perhaps others);

    I'd suspect that this is a better method to choose to maximize robustness, but if it's just going to run on something with accessible unix shells... I'd only do this to save forking costs, in that case...

    Pramatism vs. Elegance!

    Squibbie Pooh Ski Doo.

      Ahem, PRAGMATISM! doh.

      Squibbie Pooh Ski Doo.