
edesign
Deleted
Mar 4, 2000, 3:28 PM
Post #1 of 6
(2121 views)
|
Ordering in Perl
|
Can't Post
|
|
Hello! I am currently working on a perl script that takes text files in a directory and pastes them into a webpage. This allows me to easily update the news on my site. I was able to get everything to work, but because it is news, I need the text files to be pasted onto the webpage in order of newest to latest and I cannot figure out how to do it. I currently name the text files in the following format, where 00-00-00 is the date: 00-00-00_File_Name_Here.txt Could I use the titles to make the script order them? And if not, how else could I do it? Please look at what I already have of the script below, and let me know. Thanks! -Daniel #!/usr/bin/perl $newsdir = '/home/ebeanies/public_html/cgi-bin/news'; print "Content-type: text/html\n\n"; opendir THEDIR, "$newsdir" | | die "Unable to open the news!"; @allfiles = readdir THEDIR; closedir THEDIR; foreach $file (@allfiles) { if ("$newsdir/$file" =~ /\.txt/) { open (newsdir, "<$newsdir/$file"); @newsdir=<newsdir>; close(newsdir); foreach $newsdir (@newsdir) { print "$newsdir\n"; } print qq~ <!-- Line --> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td bgcolor="#ffffff" height="5"><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table> </td> </tr> <tr> <td bgcolor="#000000" height="1"><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table> </td> </tr> <tr> <td bgcolor="#ffffff" height="5"><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table> </td> </tr> </table> <!-- End Line --> ~; } }
|