#!/usr/bin/perl
#
# $Id: pics-index.pl,v 1.2 1994/09/09 14:10:28 jorgens Exp $
#
# Guess what.
#

$version = " $Revision: 1.2 $ " ;

push(@INC, join('/', $ENV{HOME}, 'lib', 'perl')) ;

require <my-version.pl> ;
require <getopts.pl> ;

&Getopts("hv") ;

&version if ($opt_v) ;

$KB = 1024 ;
$MB = $KB ** 2 ;

opendir(DIR, ".") ;
@files = readdir DIR ;
closedir DIR ;

print "<HTML>\n<HEAD>\n<TITLE>Picture Index</TITLE>\n</HEAD>\n<BODY>
<H1>Picture Index</H1>\n<HR>\n<DL>\n<PRE>\n" ;

foreach (sort @files) {
    local($mb, $kb) ;

    $file = $_ ;
    next if ($file eq "." || $file eq ".." || -d $file || $file =~ /\.html$/) ;
    ($size) = (stat($file))[7] ;
    $mb = int($size / $MB) if (int($size / $MB)) ;
    $kb = int($size / $KB) if (int($size / $KB) && $mb == 0) ;
    printf "<DD> %s<A HREF=\"%s\">%s</A> (<I>%5d %s</I>)\n",
    " " x (20 - length($file)), $file, $file,
    ($mb != 0 ? $mb : ($kb != 0 ? $kb : $size)), 
    ($mb != 0 ? "M" : ($kb != 0 ? "K" : "b"));
}
print "</PRE>\n<HR>\n<ADDRESS>Author :
<A HREF=\"http://www.pvv.unit.no/~jorgens\">Kjetil Wiekhorst Jørgensen</A>
</ADDRESS>\n</BODY>\n</HTML>\n" ;
