package NPEMap; use vars qw(@ISA @EXPORT); use warnings; use strict; use vars qw($dbname $dbhost $dbuser $dbpass); use NPEMap::Config; use DBI; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(setup_dbh print_html_err); sub setup_dbh { my $data_source = "dbi:Pg:dbname=$dbname"; $data_source .= ";host=$dbhost" if $dbhost; return DBI->connect_cached($data_source, $dbuser, $dbpass); } sub print_html_err($$) { my $err = shift; my $returnlink = shift; print "Content-type: text/html\n\n"; print "Error submitting\n"; print "

The following error occurred whilst submitting data:\n"; print CGI::escapeHTML($err); print "

$returnlink

\n"; print "\n"; } 1;