#!/usr/local/bin/perl # first argument is the ps file to convert # second argument is the "backlink" (look below for $backlink) # third argument is the title of this file. (make sure you put quotes # around the multiple-word title) # htmlize-ps frog-jump.ps frogs "The frog jumps!" $psfile = shift; $backlink = shift; #$backlink ="same_one"; WATCH THE #'s!!! $title = shift; $blname = "Back to S. Greenfield's teaching page"; $basename = $psfile; $basename =~ s/\.ps//; #mkdir("/tmp/perl-$$", 0777); #chdir("/tmp/perl-$$"); select((select(STDOUT), $| = 1)[0]); print "Generating ppm files..."; system("gs -sDEVICE=ppm -dNOPAUSE -sOutputFile=${basename}-%d.ppm $psfile < /dev/null > /dev/null 2>&1"); print "Changing ppm to gif & removing ppm ..."; @files = <${basename}-*.ppm>; $numfiles = $#files + 1; foreach $x (1 .. $numfiles) { print "page $x..."; system("/usr/local/netpbm/ppmtogif ${basename}-${x}.ppm > ${basename}-${x}.gif"); system("rm ${basename}-${x}.ppm") } print "done.\n"; print "Making HTML: "; @files = <${basename}-*.gif>; $numfiles = $#files + 1; foreach $x (1 .. $numfiles) { print "page $x..."; open(HTML, "> ${basename}-${x}.html"); print HTML < $title, page $x

EOF if ($x != 1) { $prevpage = $x - 1; print HTML < The previous page

EOF } if ($x != $numfiles) { $nextpage = $x + 1; print HTML < The next page

EOF } print HTML < ${blname}

EOF close(HTML); } print "done.\n";