#!/usr/local/bin/perl # Tour Journal use CGI qw(:all); $file="tourjournal.txt"; open(FILE, $file); $linetotal = 0; $linecounter = 0; $count = 0; while() { chomp($line = $_); $linetotal++; } close(FILE); $linetotalfinal = $linetotal; &run(); sub run { open(FILE, $file); while() { chomp($line = $_); $linecounter++; @item = split (/\|/,$line); $date = $item[0]; $comment = $item[1]; if ($linetotal == $linecounter) { $count++; } if ($linetotalfinal > 1 && $linetotal == $linecounter && $count == 1) { &first(); last; } if ($linetotalfinal > 1 && $linetotal == $linecounter && $count > 1 && $count < $linetotalfinal) { &middle(); last; } if ($linetotalfinal > 1 && $linetotal == $linecounter && $count > 1 && $count == $linetotalfinal) { &last(); last; } } close(FILE); } sub first { print "Content-type: text/html\n\n"; print qq~

Tour Journal

~; $linecounter = 0; $linetotal--; &run(); } sub middle { print qq~ ~; $linecounter = 0; $linetotal--; &run(); } sub last { print qq~
$date$comment
$date$comment
$date$comment
|

HOME ~; } #end