These preformat scripts write to standard
output so redirect it to a file. For example.
preformat3 >blah.html
Please remember to run wwwis
on the html file to include width and height tags so
the page formats faster.
#!/usr/bin/perl -w
# This script, like all the other poorly named
# preformat script will write a web page to
# standard output which includes all of the
# _small.jpg images in the current directory
# the _small.jpg will have links to their
# full sized friends.
$| = 1; # turn off output buffering
sub picBlock
{
my $filename = $_[0];
return if ! defined($filename);
my $rootname = $filename;
$rootname =~ s/_small.jpg$/.jpg/; # delete _small for name
my $alt = $rootname;
$alt =~ s/.jpg$//; # delete .jpg suffix
$alt =~ s/_/ /g; # convert underscores to spaces
$alt =~ s/\+/ \& /g; # convert + to andphersands with spaces
print "<a href=$rootname>\n";
print "<img src=$filename\n";
print "alt=\"$alt\"></a>\n";
print "<br>$alt\n";
}
my @files = `ls *small.jpg`;
chomp @files; # remove all the trailing newlines
my $numRows = 0;
print "<table><tr><td width=530>";
print "<table>";
while (@files) {
print "<tr>";
if ($numRows & 1) {
print "<td bgcolor=cccce6>\n";
} else {
print "<td bgcolor=dddddd>\n";
};
picBlock($files[0]);
print "</td>";
if (!($numRows & 1)) {
print "<td bgcolor=cccce6>\n";
} else {
print "<td bgcolor=dddddd>\n";
};
picBlock($files[1]);
print "</td></tr>\n";
$numRows++;
shift @files;
shift @files;
}
print "</table>\n";
print "</td></tr></table>\n";
|