#!/usr/bin/perl -w use CGI; use DBI; $query = new CGI; $name = $query->param("name"); print "Status: 200 Yes\nContent-type: text/plain\n\n"; $dbh = DBI->connect("DBI:mysql:nations", "randy") || die "Unable to connect"; $sth = $dbh->prepare("SELECT name, pop from nations ") || die "Could not run query"; $sth->execute() || die "Execued me" ; while (@row = $sth->fetchrow_array()) { if ($row[0] =~ m/^(.)/i) { print "Country $row[0] has pop $row[1] starts with $1 count " . $count{$1} . "
\n"; $count{$1}++; } } $dbh->disconnect; print %count; exit;