Index: comas/perl/Comas/DB.pm
===================================================================
--- comas.orig/perl/Comas/DB.pm	2004-06-11 11:21:50.000000000 -0500
+++ comas/perl/Comas/DB.pm	2004-06-11 12:34:19.000000000 -0500
@@ -132,7 +132,7 @@
     $db = {-dbname => 'comas',
 	   -dbuser => 'comas',
 	   -host => undef,
-	   -port => 5432,
+	   -port => undef,
 	   -lastMsg => ''};
 
     # Handle user-supplied parameters, checking no illegal parameters
@@ -151,11 +151,18 @@
     # Open database connection
     my %dbparam = (AutoCommit => 1, PrintError => 1, RaiseError => 0,
 		   ShowErrorStatement => 1);
-    my @dbline = ("dbi:Pg:dbname=$db->{-dbname}", $db->{-dbuser});
-    $dbline[0] .= '@'.$db->{-host} if $db->{-host};
-    push(@dbline, $db->{-dbpasswd});
-    
-    $db->{-dbh} = DBI->connect(@dbline, \%dbparam) or 
+
+    # Functional magic: Of those defined from dbname, host, port
+    # place them in a string separated by ;
+    my $dbiline = join ';' ,
+      map { "$_=$db->{-$_}" }
+        grep { defined $db->{-$_} }
+          qw(dbname host port);
+
+    $db->{-dbh} = DBI->connect("dbi:Pg:$dbiline",
+                               $db->{-dbuser},
+                               $db->{-dbpasswd},
+                               \%dbparam) or
 	carp("Failed to open database connection:\n",$DBI::errstr) &&
 	return undef;