Ignore:
Timestamp:
Oct 29, 2006, 5:02:35 PM (15 years ago)
Author:
Dominic Hargreaves
Message:

Make everything use the modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/cgi/interest.fcgi

    r82 r222  
    1313use vars qw($dbname $dbhost $dbuser $dbpass);
    1414
     15# Find our private perl libraries
     16use FindBin;
     17use lib "$FindBin::Bin/../perllib";
     18use NPEMap;
     19
    1520sub print_err;
    16 sub setup_dbh;
    17 
    18 # Read in database config
    19 my $config = 'npemap.conf';
    20 do $config or die "Can't read $config!\n";
    2121
    2222my $returnlink='<a href="/">Go back</a>';
     
    2626# No point in handling errors here since they'll get handled by the request
    2727# handler
    28 my $dbh;
    29 setup_dbh();
     28my $dbh = setup_dbh();
    3029
    3130my $cgi;
     
    3433
    3534    # In case the database went away, make sure we have a connection
    36     unless (setup_dbh()) {
     35    unless ($dbh = setup_dbh()) {
    3736        print_err('Error setting up database connection', $returnlink);
    3837        next REQUEST;
     
    104103    print "</body></html>\n";
    105104}
    106 
    107 sub setup_dbh {
    108     # $dbh is global
    109     my $data_source = "dbi:Pg:dbname=$dbname";
    110     $data_source .= ";host=$dbhost" if $dbhost;
    111     return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);
    112 }
    113 
Note: See TracChangeset for help on using the changeset viewer.