#!/usr/bin/perl require 'default.cgi'; $n = 18; # number of pages $page = $ENV{'QUERY_STRING'}; # Program begins. if ($page eq '') { $page = '1'; &print_page ("../data/quote/1.txt"); } else { if ($page =~ /\D/g) { &error ("Incorrect query string"); } else { &print_page("../data/quote/$page.txt"); } } exit; # Program ends. sub print_page { my $counter = 0; print "Content-type: text/html\n\n"; &header; print <<"MARKER";
MARKER
for ($i=1;$i<=$n ;$i++) {
print "Page $i \n"; } print " | \n\n";
### Start printing from file.
print "\n";
open (QUOTE, "@_[0]") || die "Can't open datafile.";
while () { if (/^ |
Page $page: $counter quotes on this page.