SPUG: Win32 Sorting directory by date

Bradley E. Young byoung at speakeasy.org
Tue Oct 2 20:43:31 CDT 2001


Bryan,

You might try sort combined with the filetest operators:

--
opendir(DIR, ".");

@files = sort {-M $a <=> -M $b} readdir(DIR);

print join "\n", @files;
--

Brad
Bradley E. Young     Curmudgeon
bradleyy at wrq.com    +1.206.301.6778
The reasonable man adapts himself to the world; the unreasonable
one persists in trying to adapt the world to himself. Therefore,
all progress depends on the unreasonable man.
-- George Bernard Shaw


> -----Original Message-----
> From: owner-spug-list at pm.org 
> [mailto:owner-spug-list at pm.org]On Behalf Of
> Bryan Dees
> Sent: Tuesday, October 02, 2001 17:53
> To: Spug-List (E-mail)
> Subject: SPUG: Win32 Sorting directory by date
> 
> 
> 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