From: Michael <me...@be...> - 2000-07-08 17:48:51
|
oh yeah..I had to run it seperate.. seemed to LOOP over and over if put in MY_CODE directory.. is there a way to stop it..and wait for a time.. then delete all the files in that DIR and wait for another time.. to start it again.. ----- Original Message ----- From: "Holly J. Sommer" <so...@mu...> To: <mis...@li...> Sent: Saturday, July 08, 2000 10:25 AM Subject: Re: [misterhouse-users] Re: quick Directory Index.html > Well, for one thing, you are missing a right-close-bracket to round out > your foreach-if nesting. I cleaned that up, and the below "worked": > > #!/usr/bin/perl -w > use strict; > my $Dir = '/Absolute/Path/To/Files/' ; # or whatever (I am using "D:/Misterhouse/mh/web/pictures/") > my $WebDir = '/Relative/Path/To/Files/' ; # or whatever (I am using "D:/Misterhouse/mh/web/pictures/") > my @files = glob("$Dir*.jpg") ; # let's just get jpegs > # my @files = glob("$Dir*") ; # Or get all the files > > my $count = @files ; # How many did we get? > > # Send header and the first part of an HTML file > print qq|Content-type: text/html\n\n| ; > print qq| > <!doctype html public "-//W3C//DTD HTML 3.2//EN"> > <html> > <head> > <title>JPG Files</title> > </head> > <body> > <!-- the title contains the directory and the count --> > <h2>All JPG files in $Dir ($count)</h2> > | ; > > foreach my $file ( sort @files ) { > if ( $file !~ /index\.s?html/ ) { > my $size = -s $file ; # find the file size > $size = &commify($size) ; # I find this easier to read > $file =~ s/$Dir/$WebDir/ ; # Replace absolute Dir with Web Relative Dir > my $filename = $file ; # Make a copy of the path/file name > $filename =~ s/$WebDir// ; # Remove the directory portion > # This line prints a link to the file > print qq|<a href="$file">$filename</a> ($size bytes)<br><br>\n| ; > # This line displays the image itself > # > print qq|<img src="$file" alt="$filename ($size bytes)"><br><br>\n| ; > } > } > > print qq|</body>\n</html>\n| ; # Finish our HTML > > sub commify { > local $_ = shift ; > 1 while s/^([-+]?\d+)(\d{3})/$1,$2/; > return $_ ; > } > > > ________________________________________________________ > To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365 > > |