There should be a title here
EOF
$text =~ s/\n+$/\n/g;
print INDEX " ", htq ($text), "
\n\n";
print INDEX "
\n";
print INDEX " ";
opendir DIR, $readmepath or die "$readmepath: $!\n";
my @de = grep $_ !~ /^(\..*|index\.html)$/, readdir DIR;
closedir DIR;
foreach my $de (sort @de)
{
my $fpathname = $readmepath . $de;
my @fstat = stat $fpathname;
if (@fstat == 0)
{
die "$fpathname: $!\n";
}
my @fmtime = gmtime $fstat[9];
my $fy = 1900 + $fmtime[5];
my $fm = 1 + $fmtime[4];
my $fd = $fmtime[3];
my $fsz = S_ISREG ($fstat[2]) ? sprintf '%9d', $fstat[7] : ' ' x 9;
$de .= '/' if S_ISDIR $fstat[2];
$fsz =~ s/(..)(.)(..)(.)(...)$/$1 . $2 . ($2 eq ' ' ? $2 : '_')
. $3 . $4 . ($4 eq ' ' ? $4 : '_')
. $5/e;
print INDEX $fsz;
printf INDEX " %04d-%02d-%02d", $fy, $fm, $fd;
printf INDEX " %s", htqq ($de), htq ($de);
print INDEX "\n";
}
print INDEX " \n";
print INDEX <
EOF
}
#
# htq - HTML-quote a string
#
sub htq ($)
{
my ($text) = @_;
$text =~ s/&/\&/g;
$text =~ s/\</g;
$text =~ s/>/\>/g;
return $text;
}
#
# htqq - HTML-quote a string for use as an attribute value
#
sub htqq ($)
{
my ($text) = @_;
$text = htq ($text);
$text =~ s/"/\"/g;
return $text;
}