#!/usr/bin/perl -w use strict; use DBI; use Exported qw(:All); my $db_info = "dbi:mysql:database;host=localhost"; our $dbh = DBI->connect($db_info, 'username', 'password', { PrintError => 0 }) or die("Couldn't connect to database\n"); print "info: " , getdb() , "\n"; #### #!/usr/bin/perl -w package Exported; use strict; use Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); # no default exports @EXPORT_OK = qw(&getdb); %EXPORT_TAGS = ( All => [qw(&getdb)] ); sub getdb { my $query = $main::dbh->selectrow_hashref("SELECT something FROM a_table"); return $query->{'explanation'}; }