bagder: curl-www/rfc mkindex.pl,1.3,1.4

[email protected]
Newsgroups gmane.comp.web.curl.www.cvs
Message-ID <[email protected]>
Update of /cvsroot/curl/curl-www/rfc
In directory labb.contactor.se:/var/tmp/cvs-serv22783

Modified Files:
	mkindex.pl 
Log Message:
better dir list + sort


Index: mkindex.pl
===================================================================
RCS file: /cvsroot/curl/curl-www/rfc/mkindex.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- mkindex.pl	23 Aug 2004 07:04:51 -0000	1.3
+++ mkindex.pl	23 Aug 2004 13:15:54 -0000	1.4
@@ -12,28 +12,19 @@
 }
 close(DESC);
 
-print "<table>";
-open(FILES, "ls -1t *.txt *.html 2>/dev/null|");
-@files=<FILES>;
-close(FILES);
-
-sub sortfunc {
-    my $A=$a;
-    my $B=$b;
-    $A =~ s/[a-zA-Z]//g;
-    $B =~ s/[a-zA-Z]//g;
+my $some_dir=".";
+opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
+my @files = grep { /\.(txt|html)/ && -f "$some_dir/$_" } readdir(DIR);
+closedir DIR;
 
-    return ($A <=> $B);
-}
 
-@sfiles = sort sortfunc @files;
+print "<table>";
 
 print "<tr class=\"tabletop\"><th>File name</th>",
     "<th>Size</th>",
     "<th>Description</th>",
     "</tr>";
-for(@sfiles) {
-    chop;
+for(sort @files) {
     $filename = $_;
 
     if($filename =~ /index/) {
@@ -44,11 +35,11 @@
 
     $showname =~ s/\.[a-z]*$//g;
 
-    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
      $atime,$mtime,$ctime,$blksize,$blocks)
         = stat($filename);
 
-    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
+    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
         localtime($ctime);
     $mon++;
     $year+=1900;

_______________________________________________
http://cool.haxx.se/mailman/listinfo/curl-www-commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.