in reply to File list by date

Just for fun, let's try to do this with Supersplit, which can be found here. (It's not yet in CPAN ;-)).
use SuperSplit; if ( $^O =~ /linux/){ $dir = `ls -l`; $col = 4; }else{ #sorry, no macs ;-) $dir = `dir -w`; $col = 2; } @$sortedref = sort{ $a->[$col] <=> $b->[$col] } @{supersplit('\s+','\n',$dir)}; print superjoin( $sortedref );
I tested it and it works under linux. Would be neater without the OS-checking, though.

Have fun with it

Jeroen
I was dreaming of guitarnotes that would irritate an executive kind of guy (FZ)

Replies are listed 'Best First'.
Re: Re: File list by date
by snax (Hermit) on Dec 21, 2000 at 20:56 UTC
    Heh -- non Perl advice follows :)

    If you're using linux (or most any *nix -- I think this flag is the same for most versions of ls) you should just use the -t flag and let ls do the time sorting for you. Or use -T for most recent first.

    Similarly, there are flags for dir that allow it to do the sorting, too. See dir /? for clues.

      Thanks for this thread. It's got me part of the way through a dilemma I'm trying to figure out. Can anyone tell me how I might add something like --

      "if any of these files is/are older than 5 minutes, create a file named warning_x in folder_x"?

      Thanks for any input. Dave