DBI を使用する必要があり、(CPAN )。 DBI について知らない場合は、それについて読む必要があります。本があります (Programming the Perl DBI ) ) 古いですが、まだ有効です。
次に、次のようなもの:
use strict;
use warnings;
use DBI;
# Insert your DSN's name here.
my $dsn = 'DSN NAME HERE'
# Change username and password to something more meaningful
my $dbh = DBI->connect("DBI:ODBC:$dsn", 'username', 'password')
# Prepare your sql statement (perldoc DBI for much more info).
my $sth = $dbh->prepare('select id, name from mytable');
# Execute the statement.
if ($sth->execute)
{
# This will keep returning until you run out of rows.
while (my $row = $sth->fetchrow_hashref)
{
print "ID = $row->{id}, Name = $row->{name}\n";
}
}
# Done. Close the connection.
$dbh->disconnect;