Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: read directory

by jbisbee (Pilgrim)
on Jul 08, 2006 at 01:08 UTC ( [id://559888]=note: print w/replies, xml ) Need Help??


in reply to read directory

Here is a quick example using glob, map, and sort to produce a list of files and their modified times. It's not quite a Swartzian transform, because we leave the modified time hanging around for the output.
#!/usr/bin/perl use strict; use warnings; use CGI qw(:standard); my %cache = (); my @files = sort { $b->[1] <=> $a->[1] } map { [ $_, (stat($_))[9] ] } glob('pending/*'); print header; print "<table>\n"; for my $file (@files) { print "<tr><td>$file->[0]</td><td>" . localtime( $file->[1] ) . "</td></tr>\n"; } print "</table>\n";
also in the future, put <code></code> around code you post :)

-biz-

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://559888]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-24 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found