Re: Sort by Mod Date

2004-05-14 Thread [EMAIL PROTECTED]
Thanks very much Ken, Ken, Dan, Matt, Sherm and Jarkko for your excellent examples! I really appreciate the time you've taken to share your code. Hope you don't mind, but I have a few more questions. I've been researching through my Perl books and think I understand how most of the code below wo

Re: Sort by Mod Date

2004-05-14 Thread David Cantrell
On Thu, May 13, 2004 at 07:22:38PM -0500, Ken Youens-Clark wrote: > The File::Find module can be a little cryptic, so you might be > interested to look at Randal Schwartz's "File::Finder" module ... Or Richard Clamp's File::Find::Rule. -- David Cantrell | Degenerate | http://www.cantrell.org.

Re: Sort by Mod Date

2004-05-14 Thread Jarkko Hietaniemi
Joseph Alotta wrote: > On May 13, 2004, at 11:12 PM, Matt Doughty wrote: > > >>here is my little bit for making a really short solution. >> >>--Matt >> >>#!perl >>my $dir = shift() || "."; >>opendir(DIR, $dir); >>print for(map { $_ . "\n" } sort { (stat($b))[9] <=> (stat($a))[9] } >>grep { !/^.{

Re: Sort by Mod Date

2004-05-13 Thread Sherm Pendley
On May 14, 2004, at 12:46 AM, Joseph Alotta wrote: All these solutions are still too verbose and self-documenting. Can someone write something a little shorter, maybe a one-liner? ls -lc | grep -v '^[ld].*' Or did you want one line of Perl? ;-) sherm--

Re: Sort by Mod Date

2004-05-13 Thread Joseph Alotta
On May 13, 2004, at 11:12 PM, Matt Doughty wrote: here is my little bit for making a really short solution. --Matt #!perl my $dir = shift() || "."; opendir(DIR, $dir); print for(map { $_ . "\n" } sort { (stat($b))[9] <=> (stat($a))[9] } grep { !/^.{1,2}$/ } readdir DIR ); All these solutions

Re: Sort by Mod Date

2004-05-13 Thread Matt Doughty
here is my little bit for making a really short solution. --Matt #!perl my $dir = shift() || "."; opendir(DIR, $dir); print for(map { $_ . "\n" } sort { (stat($b))[9] <=> (stat($a))[9] } grep { !/^.{1,2}$/ } readdir DIR );

Re: Sort by Mod Date

2004-05-13 Thread Dan Kogai
On May 14, 2004, at 11:53, Ken Williams wrote: Instead of using string-munging, you can use a real data structure: How come no one here is using hash? #!/usr/bin/perl -Tw use strict; my $dir = shift || '.'; my %mtime; opendir my $dh => $dir or die "$dir:$!"; foreach my $f (grep !/^\./, readdir($dh

Re: Sort by Mod Date

2004-05-13 Thread Ken Williams
On May 13, 2004, at 6:19 PM, [EMAIL PROTECTED] wrote: #!/usr/bin/perl my $dir = "/Users/jay/Desktop/Other Stuff/old stuff 4"; opendir FOLDER, $dir or die "Cannot open $dir: $!"; foreach $file (readdir FOLDER) { next if $file =~ /^\./; $path = "$dir/$file"; next unless -f $path and -r $p

Re: Sort by Mod Date

2004-05-13 Thread Ken Youens-Clark
On Thu, May 13, 2004 at 07:19:54PM -0400, [EMAIL PROTECTED] wrote: > Hello, > > I'm still extremely new to Perl, and was wondering if some > of you might mind taking a peek at the code below and > telling me if there's anything that could make it better or > more efficient? > > The code below is

Sort by Mod Date

2004-05-13 Thread [EMAIL PROTECTED]
Hello, I'm still extremely new to Perl, and was wondering if some of you might mind taking a peek at the code below and telling me if there's anything that could make it better or more efficient? The code below is my attempt at grabbing the files from a folder and then sorting them by modificatio