#!/usr/bin/perl -w use strict; use DBI; use dbmodule; END {DBModule_Close} ## do various things with the db specific to this ## script, such as: my $sth = $dbh->prepare("SELECT Foo FROM bar WHERE Foo = 'baz'"); $sth->execute; ## do various other things, which get done in lots of ## other places too, using subroutines in dbmodule: Write_Bar; #### package dbmodule; require Exporter; our @ISA = ("Exporter"); $dbh = DBI->connect("DBI:mysql:database=thinweb", "thinweb", "126368"); sub Write_Bar { $dbh->do("INSERT INTO bar (Foo,Fob,Fib) VALUES ('baz','biz','boz')"); } sub DBModule_Close { $dbh->disconnect; } our @EXPORT = qw/Write_Bar Insert_Into_BookingManager DBModule_Close/; 1;