#!/usr/local/bin/perl require 5.6.0; use warnings; use strict; use File::Spec::Functions; use File::Basename; my $gHTMLPath='/go/pics/thumbs/'; my $gthumb_dir=catdir('..','go','pics','thumbs'); ################################## # # # no user servicable parts below # # # ################################## if ($gthumb_dir=~m|/|){ $gthumb_dir.='/'; }elsif ($gthumb_dir=~m|\\|){ $gthumb_dir.='\\'; }elsif ($gthumb_dir=~m|:|){ $gthumb_dir.=':'; # we're on a Mac ??? not tested }else{ die "on unknown OS or couldn't get path at start \n" } # FILE: listthumbs.pl REVISION DATE: 09-13-2001 # # CGI to list display jpeg, gif & png files in a directory ##################### # Declarations # ##################### sub get_files($); # get a list of jpeg files; sub size_cmp(); # used in sort function compares two values sub main(); # ###################### # Run our program # ###################### main(); ###################### # Definitions # ###################### sub size_cmp(){ my @a_stat=stat($a) or die "couldn't stat\n $a \n$!\n"; my @b_stat=stat($b) or die "couldn't stat \n $b\n$!\n"; #7 is size so # sorting by size puts the duplicates next to each other #9 is modification time # sort reverse order return $b_stat[9] <=> $a_stat[9]; } sub get_files($) { my @result=glob("$_[0]*.{jpg,jpeg,png}"); if (0==@result) { die "couldn't glob in get_Files()"; } return @result; } sub main(){ my @pics=get_files($gthumb_dir); @pics=sort size_cmp @pics; for (my $i=0;$i<@pics;$i++){ $pics[$i]=basename($pics[$i]); } print "content-type: text/html\n\n"; print "\n" ; my $count=0; print '
| \n";
print ' '."\n"; print ; print " | \n";
if (0==$count% 3){
print "