#!/usr/local/bin/perl # Insert Next/Previous/Contents buttons in a set of pages. @pages = sort fragmentorder @ARGV; sub fragmentorder { $a =~ /^node([0-9]+)/; $na = $1; if ($a =~ /^node[0-9]+\.([0-9]+)\.html/) { $fa = $1; } else { $fa = 0; } $b =~ /^node([0-9]+)/; $nb = $1; if ($b =~ /^node[0-9]+\.([0-9]+)\.html/) { $fb = $1; } else { $fb = 0; } return (($na <=> $nb) || ($fa <=> $fb)); } for ($i = 0; $i <= $#pages; $i++) { open(SRC, $pages[$i]); open(DST, "> newpage.html"); select(DST); $_ = ; # Title line print "\n"; print $_; do links(); print "\n"; print "\n"; do buttons(); print "
\n"; $numlines = 0; while () { $numlines++; print $_; } if ($numlines >= 40) { print "
\n"; do buttons(); } close(SRC); close(DST); rename("newpage.html", $pages[$i]); } sub links { if ($i > 0) { print '\n"; } if ($i < $#pages) { print '\n"; } print "\n"; } sub buttons { if ($i > 0) { print 'Previous', "\n"; } if ($i < $#pages) { print 'Next', "\n"; } print 'Contents', "\n"; }