// in the main CGI script sub dbh { $main::dbh ||= DBI->connect(...); }