SPUG: Win32 Sorting directory by date
Joel Grow
largest at largest.org
Tue Oct 2 20:36:53 CDT 2001
What about something like this?
use strict;
my $dir = 'c:\\perl-scripts';
opendir(FILES, $dir);
my @files = sort { -M $a <=> -M $b } # newest files first
grep { -f } # only grab files--skip dirs
readdir FILES;
print "The files you requested:\n". join ("\n", @files) ."\n";
Joel
On Tue, 2 Oct 2001, Bryan Dees wrote:
> Hello, I'm trying to sort by date under Windows NT but not having much
> luck.
>
> What I want to do is open the directory, sort the array by their touch
> date and time then print out the contents. I've messed around with a
> couple mods (polysort, file::sort, etc.) but they still wont sort by
> the actual file touch date and time. I also tryed redirecting the
> opendir var through dir /od for example:
> opendir(FH, "c:\\winnt\\system32\\cmd.exe \/c dir \/od $Files |")
>
> But perl didn't like that either.
>
> Any ideas?
>
> Thank You,
>
> Bryan Dees
> Distributed Systems Analyst
> Airborne Express
> bryan.dees at airborne.com
>
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
>
>
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list