use DBI; $uid = getlogin(); my $dbh = DBI->connect('DBI:ODBC:test',$uid,'',{ RaiseError => 1, AutoCommit => 0}) or die "Couldn't connect to database: " . DBI->errstr; $sth = $dbh->prepare("select IDENT_NAME,FULL_NAME,PHONE from UINFO.USER_INFO_ACCESS") or die "Couldn't execute query: " . DBI->errstr; $sth->execute(); $res = $sth->fetchall_arrayref(); $line = "==============================================================================="; printf("%-20s %-30s %-20s\n","IDENT","FULL NAME","PHONE"); printf("%-20s %-30s %-20s\n",substr($line,0,20),substr($line,0,30),substr($line,0,20)); for ($i=0; $i<=$#$res; $i++) { printf("%-20s %-30s %-20s\n",substr($$res[$i][0],0,20),substr($$res[$i][1],0,30),substr($$res[$i][2],0,20)); } $dbh->commit(); $dbh->disconnect(); exit;