use DBI;
$ENV{"INFORMIXDIR"}="/xxx/xxxx";
$ENV{"INFORMIXSERVER"}="xxx";
$ENV{"DB_LOCALE"}="en_US.8859-1";
$ENV{"CLIENT_LOCALE"}="en_US.8859-1";
$dbh = DBI->;install_driver(‘Informix‘);
$dbh = DBI->;connect("dbi:Informix:$database",$user,$pwd)
|| die ("Can‘t connect to $database");
其中$database是你的dbspace名稱加上server名稱..
例如: apile@informix 就是dbspace=apile, servername= informix
$user,就是你的帳號
$pwd,就是你的密碼..
#!/usr/local/bin/perl -w
use strict;
use DBI;
my $name="ad";
my $password="ad";
my $connect_str="dbi:informix:unicom@hbdb";
my $dbh=DBI->connect($connect_str,$name,$password);
if(!defined $dbh){
die "Cannot do $dbh->connect: $DBI::errstr
";
}
else{
print "Successfully
";
}