Well, I've always used this method:
sub db_connect
{
my (
$db, # database to connect to
$dsn, # data source name
);
# Create data source string and connect ...
$dsn = "DBI:mysql:".
"database=".$cfg::params{'DB_NAME'}.";".
"host=".$cfg::params{'DB_HOST'}.";".
"port=".$cfg::params{'DB_PORT'};
$cfg::dbh = DBI->connect( $dsn, $cfg::params{'DB_USER'},
$cfg::params{'DB_PASSWD'},
{RaiseError => 0, AutoCommit => 1} );
if( $DBI::errstr)
{
exit_with_error($DBI::errstr);
}
}
where the $cfg::params are read from a text cfg file, and I've never had a prob with it not working, on many systems.
HTH
Cheers
Chris