This is a minimal working example
#!/usr/bin/perl -w
use strict;
use DBI;
my $ODBCdriver = 'SQL Server';
my $SQLserver = 'RC4FA9\SQLEXPRESS';
my $SQLport = '4433';
my $SQLdatabase= 'test';
my $SQLuser = '';
my $SQLpassword= '';
my @drivers = DBI->available_drivers;
print join(", ", @drivers), "\n";
my $d = join(", ", @drivers);
print "DBD::ODBC ";
print "not" if ($d !~ /ODBC/);
print "installed\n";
print "Connecting...\n";
my $dbh = DBI->connect("dbi:ODBC:Driver={$ODBCdriver};Server=$SQLserve
+r; Port=$SQLport;Database=$SQLdatabase;UID=$SQLuser;PWD=$SQLpassword"
+, {PrintError => 0, RaiseError => 1, FetchHashKeyName => 'NAME_lc'})
+or die "Can't connect to the database: $DBI::errstr\n";
print "Connected...\n";
print "Disconnecting...\n";
$dbh->disconnect if ($dbh);
print "Disconnected...\n";
As explained, $SQLserver does not affect the connection which always works fine. Other syntax 'Server=$SQLserver, $SQLport' does not work (but no error messages).