Please post the code that gives that error.
I guess you need to rename your sub to dbconnect like shown here. You can't use connect because it is a DBI method.
use Getopt::Long;
GetOptions("site=s" => \my $site)
or die "Error in command line arguments\n";
defined $site
or die "usage: $0 site_name\n";
my %site_map = (
site1 => { host => 'am.d.aog.com', db=>'site1', user=>'db_cad', pw=
+>'Cad123' },
site2 => { host => 'am.d.aog.com', db=>'site2', user=>'db_cad', pw
+=>'Cad123' },
);
my $dbh = dbconnect($site);
print $dbh;
sub dbconnect {
my $s = shift;
die "bad site $s" unless $site_map{$s};
my $dsn = "DBI:mysql:database=$site_map{$s}{db};host=$site_map{$s}
+{host}";
my $dbh = DBI->connect($dsn, $site_map{$s}{'current'}{user}, $site
+_map{$s}{'current'}{pw})
or die "ERROR: can't connect to database server site $s";
return $dbh;
}