#! /usr/local/bin/perl # Robustness Lab: Solution # # Begin loading the needed extensions # @extensions = ( 'require CGI; import CGI qw (:html2)', 'require CGI::Carp; import CGI::Carp qw (carpout)', 'require DBI; import DBI', ); foreach $ext (@extensions) { print STDERR "$ext\n"; eval $ext; if ($@) { print "Attempt to \"$ext\" failed, this is serious."; } } # # The file dbtype.pl sets a variable which determines the type of database # you will use. This file will be found in either /tmp or /temp. # use lib qw(/tmp /temp); eval { require 'dbtype.pl'; }; if ($@) { print "Attempt to \"require 'dbtype.pl'\" failed,\n"; print "are you sure you put it in /tmp or /temp?"; } # # Set the path, unbuffer STDOUT, and redirect errors to the browser # $ENV{PATH} = join ":", qw(/usr/bin /bin /sbin /usr/sbin /etc); $| = 1; carpout(\*STDOUT); # # Declare variables # my( $dbname ); my( $dbh, $rv, $sth ); # # Accept the CGI request # my( $q ) = new CGI; # # Hard-code the database name # $dbname = "test_nile"; # # Send the HTTP header # print $q->header; # # Set the
\n"; # # Class routine to dump the contents of the rows previously SELECT'ed # DBI::dump_results($sth, 100); print "\n\n"; # # We're done with this statement, free up the resources # $sth->finish; # # Disconnect from the database, we're done! # $dbh->disconnect; # # Send