#!/usr/bin/perl
$start=$ARGV[0];
$num=$ARGV[1];
if (!$start) {
$start=1;
}
if (!$num) {
$num=5;
}
open(DIR,"ls -r 1*txt |");
print "Content-type: text/html\n\n";
print "\n";
@months=("Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec");
#print "Start: $start
\n";
#print "Num: $num
\n";
$top=`cat main.html`;
print $top;
$total=0;
while ($line=
) {
chop($line);
$file[$total]=$line;
$total++;
}
$end=$start+$num-1;
if ($end>$total) {
$end=$total;
}
print "\n";
for ($i=$start-1;$i<$end;$i++) {
open(IN,$file[$i]);
$title=;
chop($title);
$date=$file[$i];
$date=~s/.txt//;
$time=$date;
$time=~s/.*\.//;
$hour=substr($time,0,2);
$time=substr($time,2,2);
# substr($time,2,0)=":";
if ($hour<12) {
$time.=" AM";
if ($hour==0) {
$hour=12;
}
} else {
$time.=" PM";
$hour-=12;
}
if ($hour==0) {
$hour=12;
}
$year=substr($date,0,4);
$mon=substr($date,4,2);
$day=substr($date,6,2);
$monthname=$months[$mon-1];
$dayofweek=`date -d '$mon/$day/$year' +%A`;
chop($dayofweek);
print "$title | $dayofweek, $monthname $day, $year $hour:$time |
\n";
print "\n";
while ($in=) {
print $in;
}
print "\n";
# print " \n";
print " |
\n";
}
print "
\n";
print "\n";
$bottom=`cat bottom.html`;
print $bottom;