#!c:\perl\bin\perl.exe use strict; use warnings; use DBI; use CGI; my $q=new CGI; my %sm = $q->Vars(); my $word = $sm{concordance}; print $q->header(); print $q->start_html(-title=>'Dickens Concordance'); print qq[
]; #Count number of lines in db $db = DBI->connect('dbi:mysql:lit:localhost', 'user', 'pw'); my $row = $db->selectrow_arrayref('SELECT COUNT(*) FROM dickens'); my $count = $row->[0]; my $Page_Size = "50"; my $first = $q->param("start") || 1; my $last = $first + $Page_Size - 1; $last = $count if $last > $count; #Query the db my $results = $db->selectall_arrayref('SELECT word ,line FROM dickens WHERE word="$concordance" LIMIT 50'); for (my $i=$first; $i<= $last; $i++) { my $user = $results->[$i-1]; printf("%d