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/bad-postcode.fcgi

    r215 r222  
    1212use vars qw($dbname $dbhost $dbuser $dbpass);
    1313
     14# Find our private perl libraries
     15use FindBin;
     16use lib "$FindBin::Bin/../perllib";
     17use NPEMap;
     18
    1419sub print_err;
    15 sub setup_dbh;
    16 
    17 # Read in database config
    18 my $config = 'npemap.conf';
    19 do $config or die "Can't read $config!\n";
    2020
    2121# Set up database handler to try and make sure it's ready for the first
     
    2323# No point in handling errors here since they'll get handled by the request
    2424# handler
    25 my $dbh;
    26 setup_dbh();
     25my $dbh = setup_dbh();
    2726
    2827my $returnBaseURL = '';
     
    4241
    4342    # In case the database went away, make sure we have a connection
    44     unless (setup_dbh()) {
     43    unless ($dbh = setup_dbh()) {
    4544        print_err('Error setting up database connection', $returnlink);
    4645        next REQUEST;
     
    9493    print "</body></html>\n";
    9594}
    96 
    97 sub setup_dbh {
    98     # $dbh is global
    99     my $data_source = "dbi:Pg:dbname=$dbname";
    100     $data_source .= ";host=$dbhost" if $dbhost;
    101     return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);
    102 }
    103 
Note: See TracChangeset for help on using the changeset viewer.