index.pl
--------
#!/usr/bin/perl
use strict;
use vars qw($dbh %sth %config %globals);
use CGI qw(:standard);
use DBI;
use My::Database;
use My::Globals;
use My::Package_A;
connectDB();
my $content = "dbh = $dbh
";
outputHTML($content);
exit;
-----------------------
package My::Database;
use strict;
use base 'Exporter';
our $VERSION = '1.0';
our @ISA = ('Exporter');
our @EXPORT = qw(connectDB $dbh);
use vars qw($dbh);
sub connectDB
{
$dbh = DBI->connect("DBI:mysql:database='database_name';host='host_name'", 'user_name', 'password', {RaiseError => 1, AutoCommit => 0});
}
1;
----------------------------------
package My::Globals;
use strict;
use base 'Exporter';
our $VERSION = '1.0';
our @ISA = ('Exporter');
our @EXPORT = qw(%globals);
use vars qw(%globals);
sub load_globals
{
%gloabls = ();
$globals{'image_directory'} = '/path/to/image/directory';
}
1;
---------------------------
package My::Package_A;
use strict;
use base 'Exporter';
use CGI qw(:standard);
our $VERSION = '1.0';
our @ISA = ('Exporter');
our @EXPORT = qw(outputHTML);
sub outputHTML
{
my ($data) = $dbh->selectrow_array(qq|SELECT data FROM table WHERE 1|);
my $html = shift;
print header;
print <
$html

$data