#!/usr/bin/perl -w use strict; use warnings; use DBI; my $dsn = "DBI:mysql:SOME_DATABASE:localhost"; my $user = "tom"; my $pwd = "*********"; my $dbh = DBI->connect($dsn, $user, $pwd) or die; my $sql = qq{SELECT `SOME_FIELD` FROM `SOME_TABLE`}; my $sth = $dbh->prepare($sql); $sth->execute; while (my $result = $sth->fetchrow_array) { print "$result\n"; } $sth->finish; $dbh->disconnect; exit;